0s autopkgtest [20:36:09]: starting date and time: 2025-06-05 20:36:09+0000 0s autopkgtest [20:36:09]: git checkout: 9986aa8c Merge branch 'skia/fix_network_interface' into 'ubuntu/production' 0s autopkgtest [20:36:09]: host juju-7f2275-prod-proposed-migration-environment-23; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.hkxpfah6/out --timeout-copy=6000 -a i386 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:python3-defaults --apt-upgrade pandas --timeout-short=300 --timeout-copy=20000 --timeout-test=20000 --timeout-build=20000 --env=ADT_TEST_TRIGGERS=python3-defaults/3.13.4-1 -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor autopkgtest-cpu4-ram16-disk100-amd64 --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-23@sto01-2.secgroup --name adt-questing-i386-pandas-20250605-203609-juju-7f2275-prod-proposed-migration-environment-23-ed83df8c-3f8f-4a29-ad14-3ceffaeaa5da --image adt/ubuntu-questing-amd64-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-23 --net-id=net_prod-autopkgtest-workers-amd64 -e TERM=linux --mirror=http://ftpmaster.internal/ubuntu/ 63s autopkgtest [20:37:12]: testbed dpkg architecture: amd64 63s autopkgtest [20:37:12]: testbed apt version: 3.1.0ubuntu3 63s autopkgtest [20:37:12]: @@@@@@@@@@@@@@@@@@@@ test bed setup 63s autopkgtest [20:37:12]: testbed release detected to be: None 64s autopkgtest [20:37:13]: updating testbed package index (apt update) 64s Get:1 http://ftpmaster.internal/ubuntu questing-proposed InRelease [249 kB] 64s Hit:2 http://ftpmaster.internal/ubuntu questing InRelease 64s Hit:3 http://ftpmaster.internal/ubuntu questing-updates InRelease 64s Hit:4 http://ftpmaster.internal/ubuntu questing-security InRelease 64s Get:5 http://ftpmaster.internal/ubuntu questing-proposed/universe Sources [438 kB] 64s Get:6 http://ftpmaster.internal/ubuntu questing-proposed/multiverse Sources [13.0 kB] 64s Get:7 http://ftpmaster.internal/ubuntu questing-proposed/restricted Sources [3168 B] 64s Get:8 http://ftpmaster.internal/ubuntu questing-proposed/main Sources [55.3 kB] 64s Get:9 http://ftpmaster.internal/ubuntu questing-proposed/main i386 Packages [46.5 kB] 64s Get:10 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 Packages [82.1 kB] 64s Get:11 http://ftpmaster.internal/ubuntu questing-proposed/restricted i386 Packages [2420 B] 64s Get:12 http://ftpmaster.internal/ubuntu questing-proposed/restricted amd64 Packages [8100 B] 65s Get:13 http://ftpmaster.internal/ubuntu questing-proposed/universe i386 Packages [163 kB] 65s Get:14 http://ftpmaster.internal/ubuntu questing-proposed/universe amd64 Packages [388 kB] 65s Get:15 http://ftpmaster.internal/ubuntu questing-proposed/multiverse i386 Packages [4068 B] 65s Get:16 http://ftpmaster.internal/ubuntu questing-proposed/multiverse amd64 Packages [10.8 kB] 65s Fetched 1464 kB in 1s (2493 kB/s) 65s Reading package lists... 66s autopkgtest [20:37:15]: upgrading testbed (apt dist-upgrade and autopurge) 66s Reading package lists... 66s Building dependency tree... 66s Reading state information... 66s Calculating upgrade... 66s The following packages will be upgraded: 66s libpython3-stdlib python3 python3-minimal 66s 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 66s Need to get 62.3 kB of archives. 66s After this operation, 0 B of additional disk space will be used. 66s Get:1 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3-minimal amd64 3.13.4-1 [27.9 kB] 66s Get:2 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3 amd64 3.13.4-1 [24.0 kB] 66s Get:3 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 libpython3-stdlib amd64 3.13.4-1 [10.5 kB] 67s Fetched 62.3 kB in 0s (0 B/s) 67s (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 ... 80922 files and directories currently installed.) 67s Preparing to unpack .../python3-minimal_3.13.4-1_amd64.deb ... 67s Unpacking python3-minimal (3.13.4-1) over (3.13.3-1) ... 67s Setting up python3-minimal (3.13.4-1) ... 67s (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 ... 80922 files and directories currently installed.) 67s Preparing to unpack .../python3_3.13.4-1_amd64.deb ... 67s Unpacking python3 (3.13.4-1) over (3.13.3-1) ... 67s Preparing to unpack .../libpython3-stdlib_3.13.4-1_amd64.deb ... 67s Unpacking libpython3-stdlib:amd64 (3.13.4-1) over (3.13.3-1) ... 67s Setting up libpython3-stdlib:amd64 (3.13.4-1) ... 67s Setting up python3 (3.13.4-1) ... 67s Processing triggers for man-db (2.13.1-1) ... 68s Reading package lists... 68s Building dependency tree... 68s Reading state information... 68s Solving dependencies... 68s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 70s autopkgtest [20:37:19]: testbed running kernel: Linux 6.14.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Sun Apr 6 15:05:05 UTC 2025 71s autopkgtest [20:37:20]: @@@@@@@@@@@@@@@@@@@@ apt-source pandas 73s Get:1 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (dsc) [5546 B] 73s Get:2 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (tar) [11.2 MB] 73s Get:3 http://ftpmaster.internal/ubuntu questing/universe pandas 2.2.3+dfsg-9 (diff) [112 kB] 73s gpgv: Signature made Sat Mar 29 14:46:18 2025 UTC 73s gpgv: using RSA key 67CB311005C4EDBE32175308DEE50D0D567EA266 73s gpgv: issuer "rebecca_palmer@zoho.com" 73s gpgv: Can't check signature: No public key 73s dpkg-source: warning: cannot verify inline signature for ./pandas_2.2.3+dfsg-9.dsc: no acceptable signature found 74s autopkgtest [20:37:23]: testing package pandas version 2.2.3+dfsg-9 74s autopkgtest [20:37:23]: build not needed 77s autopkgtest [20:37:26]: test command1: preparing testbed 77s Reading package lists... 77s Building dependency tree... 77s Reading state information... 77s Solving dependencies... 77s The following NEW packages will be installed: 77s libblas3 libgfortran5 liblapack3 python3-numpy python3-numpy-dev 77s python3-pandas python3-pandas-lib python3-pytz 77s 0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded. 77s Need to get 17.6 MB of archives. 77s After this operation, 89.6 MB of additional disk space will be used. 77s Get:1 http://ftpmaster.internal/ubuntu questing/main amd64 python3-numpy-dev amd64 1:2.2.4+ds-1 [147 kB] 77s Get:2 http://ftpmaster.internal/ubuntu questing/main amd64 libblas3 amd64 3.12.1-2build1 [262 kB] 77s Get:3 http://ftpmaster.internal/ubuntu questing/main amd64 libgfortran5 amd64 15.1.0-5ubuntu1 [927 kB] 78s Get:4 http://ftpmaster.internal/ubuntu questing/main amd64 liblapack3 amd64 3.12.1-2build1 [2672 kB] 78s Get:5 http://ftpmaster.internal/ubuntu questing/main amd64 python3-numpy amd64 1:2.2.4+ds-1 [5383 kB] 78s Get:6 http://ftpmaster.internal/ubuntu questing/main amd64 python3-pytz all 2025.2-3 [163 kB] 78s Get:7 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pandas-lib amd64 2.2.3+dfsg-9 [4949 kB] 79s Get:8 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pandas all 2.2.3+dfsg-9 [3112 kB] 79s Fetched 17.6 MB in 2s (10.9 MB/s) 79s Selecting previously unselected package python3-numpy-dev:amd64. 79s (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 ... 80922 files and directories currently installed.) 79s Preparing to unpack .../0-python3-numpy-dev_1%3a2.2.4+ds-1_amd64.deb ... 79s Unpacking python3-numpy-dev:amd64 (1:2.2.4+ds-1) ... 79s Selecting previously unselected package libblas3:amd64. 79s Preparing to unpack .../1-libblas3_3.12.1-2build1_amd64.deb ... 79s Unpacking libblas3:amd64 (3.12.1-2build1) ... 79s Selecting previously unselected package libgfortran5:amd64. 79s Preparing to unpack .../2-libgfortran5_15.1.0-5ubuntu1_amd64.deb ... 79s Unpacking libgfortran5:amd64 (15.1.0-5ubuntu1) ... 79s Selecting previously unselected package liblapack3:amd64. 79s Preparing to unpack .../3-liblapack3_3.12.1-2build1_amd64.deb ... 79s Unpacking liblapack3:amd64 (3.12.1-2build1) ... 79s Selecting previously unselected package python3-numpy. 79s Preparing to unpack .../4-python3-numpy_1%3a2.2.4+ds-1_amd64.deb ... 79s Unpacking python3-numpy (1:2.2.4+ds-1) ... 79s Selecting previously unselected package python3-pytz. 79s Preparing to unpack .../5-python3-pytz_2025.2-3_all.deb ... 79s Unpacking python3-pytz (2025.2-3) ... 79s Selecting previously unselected package python3-pandas-lib:amd64. 79s Preparing to unpack .../6-python3-pandas-lib_2.2.3+dfsg-9_amd64.deb ... 79s Unpacking python3-pandas-lib:amd64 (2.2.3+dfsg-9) ... 79s Selecting previously unselected package python3-pandas. 79s Preparing to unpack .../7-python3-pandas_2.2.3+dfsg-9_all.deb ... 79s Unpacking python3-pandas (2.2.3+dfsg-9) ... 80s Setting up python3-pytz (2025.2-3) ... 80s Setting up libblas3:amd64 (3.12.1-2build1) ... 80s update-alternatives: using /usr/lib/x86_64-linux-gnu/blas/libblas.so.3 to provide /usr/lib/x86_64-linux-gnu/libblas.so.3 (libblas.so.3-x86_64-linux-gnu) in auto mode 80s Setting up python3-numpy-dev:amd64 (1:2.2.4+ds-1) ... 80s Setting up libgfortran5:amd64 (15.1.0-5ubuntu1) ... 80s Setting up liblapack3:amd64 (3.12.1-2build1) ... 80s update-alternatives: using /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/x86_64-linux-gnu/liblapack.so.3 (liblapack.so.3-x86_64-linux-gnu) in auto mode 80s Setting up python3-numpy (1:2.2.4+ds-1) ... 81s Setting up python3-pandas-lib:amd64 (2.2.3+dfsg-9) ... 81s Setting up python3-pandas (2.2.3+dfsg-9) ... 84s Processing triggers for man-db (2.13.1-1) ... 84s Processing triggers for libc-bin (2.41-6ubuntu2) ... 85s autopkgtest [20:37:34]: testbed environment configured for cross-architecture building 85s autopkgtest [20:37:34]: test command1: cd "$AUTOPKGTEST_TMP" && python3 -c "import pandas;a=pandas.DataFrame([[1,2],[3,4]])" 85s autopkgtest [20:37:34]: test command1: [----------------------- 86s autopkgtest [20:37:35]: test command1: -----------------------] 87s autopkgtest [20:37:36]: test command1: - - - - - - - - - - results - - - - - - - - - - 87s command1 PASS 87s autopkgtest [20:37:36]: test unittests3: preparing testbed 87s Reading package lists... 87s Building dependency tree... 87s Reading state information... 87s Solving dependencies... 87s The following NEW packages will be installed: 87s blt fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-mono 87s fonts-lyx libaec0 libavahi-client3 libavahi-common-data libavahi-common3 87s libblosc1 libblosc2-4 libcups2t64 libdeflate0 libdouble-conversion3 87s libdrm-intel1 libegl-mesa0 libegl1 libfontconfig1 libfontenc1 libgbm1 libgl1 87s libgl1-mesa-dri libglvnd0 libglx-mesa0 libglx0 libgomp1 libgraphite2-3 87s libharfbuzz0b libhdf5-310 libice6 libimagequant0 libinput-bin libinput10 87s libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui liblcms2-2 87s liblerc4 libmd4c0 libmtdev1t64 libopenjp2-7 libpciaccess0 libpcre2-16-0 87s libpixman-1-0 libqhull-r8.0 libqt5core5t64 libqt5dbus5t64 libqt5designer5 87s libqt5gui5t64 libqt5help5 libqt5network5t64 libqt5printsupport5t64 87s libqt5sql5t64 libqt5test5t64 libqt5widgets5t64 libqt5xml5t64 libraqm0 87s libsharpyuv0 libsm6 libsnappy1v5 libsz2 libtcl8.6 libtiff6 libtk8.6 87s libvulkan1 libwacom-common libwacom9 libwayland-client0 libwayland-server0 87s libwebp7 libwebpdemux2 libwebpmux3 libx11-xcb1 libxaw7 libxcb-dri3-0 87s libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0 87s libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 87s libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb-xinput0 87s libxcb-xkb1 libxfont2 libxft2 libxkbcommon-x11-0 libxkbfile1 libxmu6 libxpm4 87s libxrandr2 libxrender1 libxshmfence1 libxslt1.1 libxss1 libxt6t64 87s libxxf86vm1 locales-all mesa-libgallium python-matplotlib-data 87s python-tables-data python3-all python3-async-generator python3-bottleneck 87s python3-brotli python3-bs4 python3-click python3-cloudpickle 87s python3-contourpy python3-cpuinfo python3-cycler python3-dask 87s python3-decorator python3-defusedxml python3-et-xmlfile python3-execnet 87s python3-fonttools python3-fs python3-fsspec python3-greenlet 87s python3-html5lib python3-hypothesis python3-iniconfig python3-kiwisolver 87s python3-locket python3-lxml python3-lz4 python3-matplotlib python3-mpmath 87s python3-numexpr python3-odf python3-openpyxl python3-partd python3-pil 87s python3-pil.imagetk python3-platformdirs python3-pluggy python3-py 87s python3-pyqt5 python3-pyqt5.sip python3-pyreadstat python3-pytest 87s python3-pytest-asyncio python3-pytest-forked python3-pytest-localserver 87s python3-pytest-xdist python3-pytestqt python3-scipy python3-sortedcontainers 87s python3-soupsieve python3-sqlalchemy python3-sympy python3-tables 87s python3-tables-lib python3-tabulate python3-tk python3-toolz python3-tz 87s python3-ufolib2 python3-webencodings python3-werkzeug python3-xarray 87s python3-xlrd python3-xlsxwriter python3-zstandard python3.13-tk tk8.6-blt2.5 87s tzdata-legacy unicode-data x11-common x11-xkb-utils xsel xserver-common xvfb 88s 0 upgraded, 184 newly installed, 0 to remove and 0 not upgraded. 88s Need to get 115 MB of archives. 88s After this operation, 667 MB of additional disk space will be used. 88s Get:1 http://ftpmaster.internal/ubuntu questing/main amd64 libtcl8.6 amd64 8.6.16+dfsg-1 [1086 kB] 88s Get:2 http://ftpmaster.internal/ubuntu questing/main amd64 fonts-dejavu-mono all 2.37-8 [502 kB] 88s Get:3 http://ftpmaster.internal/ubuntu questing/main amd64 fonts-dejavu-core all 2.37-8 [835 kB] 88s Get:4 http://ftpmaster.internal/ubuntu questing/main amd64 fontconfig-config amd64 2.15.0-2.2ubuntu1 [37.8 kB] 88s Get:5 http://ftpmaster.internal/ubuntu questing/main amd64 libfontconfig1 amd64 2.15.0-2.2ubuntu1 [164 kB] 88s Get:6 http://ftpmaster.internal/ubuntu questing/main amd64 libxrender1 amd64 1:0.9.12-1 [19.8 kB] 88s Get:7 http://ftpmaster.internal/ubuntu questing/main amd64 libxft2 amd64 2.3.6-1build1 [45.3 kB] 88s Get:8 http://ftpmaster.internal/ubuntu questing/main amd64 x11-common all 1:7.7+23ubuntu4 [21.8 kB] 88s Get:9 http://ftpmaster.internal/ubuntu questing/main amd64 libxss1 amd64 1:1.2.3-1build3 [7204 B] 88s Get:10 http://ftpmaster.internal/ubuntu questing/main amd64 libtk8.6 amd64 8.6.16-1 [868 kB] 88s Get:11 http://ftpmaster.internal/ubuntu questing/main amd64 tk8.6-blt2.5 amd64 2.5.3+dfsg-8 [694 kB] 88s Get:12 http://ftpmaster.internal/ubuntu questing/main amd64 blt amd64 2.5.3+dfsg-8 [4824 B] 88s Get:13 http://ftpmaster.internal/ubuntu questing/main amd64 fontconfig amd64 2.15.0-2.2ubuntu1 [180 kB] 88s Get:14 http://ftpmaster.internal/ubuntu questing/universe amd64 fonts-lyx all 2.4.3-1 [171 kB] 88s Get:15 http://ftpmaster.internal/ubuntu questing/universe amd64 libaec0 amd64 1.1.3-1 [22.7 kB] 88s Get:16 http://ftpmaster.internal/ubuntu questing/main amd64 libavahi-common-data amd64 0.8-16ubuntu2 [31.0 kB] 88s Get:17 http://ftpmaster.internal/ubuntu questing/main amd64 libavahi-common3 amd64 0.8-16ubuntu2 [23.6 kB] 88s Get:18 http://ftpmaster.internal/ubuntu questing/main amd64 libavahi-client3 amd64 0.8-16ubuntu2 [27.5 kB] 88s Get:19 http://ftpmaster.internal/ubuntu questing/main amd64 libsnappy1v5 amd64 1.2.2-1 [30.9 kB] 88s Get:20 http://ftpmaster.internal/ubuntu questing/universe amd64 libblosc1 amd64 1.21.5+ds-1build1 [36.2 kB] 88s Get:21 http://ftpmaster.internal/ubuntu questing/universe amd64 libblosc2-4 amd64 2.17.1+ds-1 [171 kB] 88s Get:22 http://ftpmaster.internal/ubuntu questing/main amd64 libcups2t64 amd64 2.4.12-0ubuntu1 [292 kB] 88s Get:23 http://ftpmaster.internal/ubuntu questing/main amd64 libdeflate0 amd64 1.23-2 [49.9 kB] 88s Get:24 http://ftpmaster.internal/ubuntu questing/universe amd64 libdouble-conversion3 amd64 3.3.1-1 [41.7 kB] 88s Get:25 http://ftpmaster.internal/ubuntu questing/main amd64 libpciaccess0 amd64 0.18.1-1ubuntu1 [18.9 kB] 88s Get:26 http://ftpmaster.internal/ubuntu questing/main amd64 libdrm-intel1 amd64 2.4.124-2 [68.9 kB] 88s Get:27 http://ftpmaster.internal/ubuntu questing/main amd64 libwayland-server0 amd64 1.23.1-3build1 [35.6 kB] 88s Get:28 http://ftpmaster.internal/ubuntu questing/main amd64 libx11-xcb1 amd64 2:1.8.12-1 [7968 B] 88s Get:29 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-dri3-0 amd64 1.17.0-2 [7508 B] 88s Get:30 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-present0 amd64 1.17.0-2 [6064 B] 88s Get:31 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-randr0 amd64 1.17.0-2 [17.9 kB] 88s Get:32 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-sync1 amd64 1.17.0-2 [9312 B] 88s Get:33 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xfixes0 amd64 1.17.0-2 [10.2 kB] 88s Get:34 http://ftpmaster.internal/ubuntu questing/main amd64 libxshmfence1 amd64 1.3.3-1 [5262 B] 88s Get:35 http://ftpmaster.internal/ubuntu questing/main amd64 mesa-libgallium amd64 25.0.7-0ubuntu1 [10.4 MB] 88s Get:36 http://ftpmaster.internal/ubuntu questing/main amd64 libgbm1 amd64 25.0.7-0ubuntu1 [33.1 kB] 88s Get:37 http://ftpmaster.internal/ubuntu questing/main amd64 libwayland-client0 amd64 1.23.1-3build1 [28.3 kB] 88s Get:38 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-shm0 amd64 1.17.0-2 [5758 B] 88s Get:39 http://ftpmaster.internal/ubuntu questing/main amd64 libegl-mesa0 amd64 25.0.7-0ubuntu1 [123 kB] 88s Get:40 http://ftpmaster.internal/ubuntu questing/main amd64 libfontenc1 amd64 1:1.1.8-1build1 [14.0 kB] 88s Get:41 http://ftpmaster.internal/ubuntu questing/main amd64 libvulkan1 amd64 1.4.309.0-1 [145 kB] 88s Get:42 http://ftpmaster.internal/ubuntu questing/main amd64 libgl1-mesa-dri amd64 25.0.7-0ubuntu1 [35.7 kB] 88s Get:43 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-glx0 amd64 1.17.0-2 [24.8 kB] 88s Get:44 http://ftpmaster.internal/ubuntu questing/main amd64 libxxf86vm1 amd64 1:1.1.4-1build4 [9282 B] 88s Get:45 http://ftpmaster.internal/ubuntu questing/main amd64 libglx-mesa0 amd64 25.0.7-0ubuntu1 [141 kB] 88s Get:46 http://ftpmaster.internal/ubuntu questing/main amd64 libgomp1 amd64 15.1.0-5ubuntu1 [151 kB] 88s Get:47 http://ftpmaster.internal/ubuntu questing/main amd64 libgraphite2-3 amd64 1.3.14-2ubuntu1 [73.1 kB] 88s Get:48 http://ftpmaster.internal/ubuntu questing/main amd64 libharfbuzz0b amd64 10.2.0-1 [543 kB] 88s Get:49 http://ftpmaster.internal/ubuntu questing/universe amd64 libsz2 amd64 1.1.3-1 [5456 B] 88s Get:50 http://ftpmaster.internal/ubuntu questing/universe amd64 libhdf5-310 amd64 1.14.5+repack-3build1 [1411 kB] 88s Get:51 http://ftpmaster.internal/ubuntu questing/main amd64 libice6 amd64 2:1.1.1-1 [44.1 kB] 88s Get:52 http://ftpmaster.internal/ubuntu questing/main amd64 libimagequant0 amd64 2.18.0-1build1 [36.3 kB] 88s Get:53 http://ftpmaster.internal/ubuntu questing/main amd64 libwacom-common all 2.14.0-1build1 [103 kB] 88s Get:54 http://ftpmaster.internal/ubuntu questing/main amd64 libwacom9 amd64 2.14.0-1build1 [26.7 kB] 88s Get:55 http://ftpmaster.internal/ubuntu questing/main amd64 libinput-bin amd64 1.28.1-1 [23.6 kB] 88s Get:56 http://ftpmaster.internal/ubuntu questing/main amd64 libmtdev1t64 amd64 1.1.7-1 [16.3 kB] 88s Get:57 http://ftpmaster.internal/ubuntu questing/main amd64 libinput10 amd64 1.28.1-1 [144 kB] 88s Get:58 http://ftpmaster.internal/ubuntu questing/main amd64 libjpeg-turbo8 amd64 2.1.5-3ubuntu2 [179 kB] 88s Get:59 http://ftpmaster.internal/ubuntu questing/main amd64 libjpeg8 amd64 8c-2ubuntu11 [2148 B] 88s Get:60 http://ftpmaster.internal/ubuntu questing/main amd64 libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 88s Get:61 http://ftpmaster.internal/ubuntu questing/universe amd64 libjs-jquery-ui all 1.13.2+dfsg-1 [252 kB] 88s Get:62 http://ftpmaster.internal/ubuntu questing/main amd64 liblcms2-2 amd64 2.16-2 [212 kB] 88s Get:63 http://ftpmaster.internal/ubuntu questing/main amd64 liblerc4 amd64 4.0.0+ds-5ubuntu1 [271 kB] 88s Get:64 http://ftpmaster.internal/ubuntu questing/universe amd64 libmd4c0 amd64 0.5.2-2 [50.1 kB] 88s Get:65 http://ftpmaster.internal/ubuntu questing/main amd64 libpcre2-16-0 amd64 10.45-1 [268 kB] 88s Get:66 http://ftpmaster.internal/ubuntu questing/main amd64 libpixman-1-0 amd64 0.44.0-3 [427 kB] 88s Get:67 http://ftpmaster.internal/ubuntu questing/universe amd64 libqhull-r8.0 amd64 2020.2-6build1 [193 kB] 88s Get:68 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5core5t64 amd64 5.15.15+dfsg-5ubuntu1 [2035 kB] 88s Get:69 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5dbus5t64 amd64 5.15.15+dfsg-5ubuntu1 [221 kB] 88s Get:70 http://ftpmaster.internal/ubuntu questing/main amd64 libglvnd0 amd64 1.7.0-1build1 [69.6 kB] 88s Get:71 http://ftpmaster.internal/ubuntu questing/main amd64 libegl1 amd64 1.7.0-1build1 [28.7 kB] 88s Get:72 http://ftpmaster.internal/ubuntu questing/main amd64 libglx0 amd64 1.7.0-1build1 [38.6 kB] 88s Get:73 http://ftpmaster.internal/ubuntu questing/main amd64 libgl1 amd64 1.7.0-1build1 [102 kB] 88s Get:74 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5network5t64 amd64 5.15.15+dfsg-5ubuntu1 [724 kB] 88s Get:75 http://ftpmaster.internal/ubuntu questing/main amd64 libsm6 amd64 2:1.2.6-1 [16.4 kB] 88s Get:76 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-icccm4 amd64 0.4.2-1 [11.1 kB] 88s Get:77 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-util1 amd64 0.4.1-1 [11.2 kB] 88s Get:78 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-image0 amd64 0.4.0-2build1 [10.8 kB] 88s Get:79 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-keysyms1 amd64 0.4.1-1 [8738 B] 88s Get:80 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-render0 amd64 1.17.0-2 [16.2 kB] 88s Get:81 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-render-util0 amd64 0.3.10-1 [10.8 kB] 88s Get:82 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-shape0 amd64 1.17.0-2 [6092 B] 88s Get:83 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xinerama0 amd64 1.17.0-2 [5412 B] 88s Get:84 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xinput0 amd64 1.17.0-2 [33.2 kB] 88s Get:85 http://ftpmaster.internal/ubuntu questing/main amd64 libxcb-xkb1 amd64 1.17.0-2 [32.3 kB] 88s Get:86 http://ftpmaster.internal/ubuntu questing/main amd64 libxkbcommon-x11-0 amd64 1.7.0-2ubuntu1 [16.4 kB] 88s Get:87 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5gui5t64 amd64 5.15.15+dfsg-5ubuntu1 [3788 kB] 88s Get:88 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5widgets5t64 amd64 5.15.15+dfsg-5ubuntu1 [2560 kB] 88s Get:89 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5xml5t64 amd64 5.15.15+dfsg-5ubuntu1 [124 kB] 88s Get:90 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5designer5 amd64 5.15.15-6build1 [2827 kB] 88s Get:91 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5sql5t64 amd64 5.15.15+dfsg-5ubuntu1 [122 kB] 88s Get:92 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5help5 amd64 5.15.15-6build1 [162 kB] 88s Get:93 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5printsupport5t64 amd64 5.15.15+dfsg-5ubuntu1 [207 kB] 88s Get:94 http://ftpmaster.internal/ubuntu questing/universe amd64 libqt5test5t64 amd64 5.15.15+dfsg-5ubuntu1 [149 kB] 88s Get:95 http://ftpmaster.internal/ubuntu questing/main amd64 libraqm0 amd64 0.10.2-1 [17.2 kB] 88s Get:96 http://ftpmaster.internal/ubuntu questing/main amd64 libsharpyuv0 amd64 1.5.0-0.1 [25.9 kB] 88s Get:97 http://ftpmaster.internal/ubuntu questing/main amd64 libjbig0 amd64 2.1-6.1ubuntu2 [29.7 kB] 88s Get:98 http://ftpmaster.internal/ubuntu questing/main amd64 libwebp7 amd64 1.5.0-0.1 [378 kB] 88s Get:99 http://ftpmaster.internal/ubuntu questing/main amd64 libtiff6 amd64 4.7.0-3ubuntu1 [204 kB] 88s Get:100 http://ftpmaster.internal/ubuntu questing/main amd64 libwebpdemux2 amd64 1.5.0-0.1 [13.0 kB] 88s Get:101 http://ftpmaster.internal/ubuntu questing/main amd64 libwebpmux3 amd64 1.5.0-0.1 [27.6 kB] 88s Get:102 http://ftpmaster.internal/ubuntu questing/main amd64 libxt6t64 amd64 1:1.2.1-1.2build1 [171 kB] 88s Get:103 http://ftpmaster.internal/ubuntu questing/main amd64 libxmu6 amd64 2:1.1.3-3build2 [47.6 kB] 88s Get:104 http://ftpmaster.internal/ubuntu questing/main amd64 libxpm4 amd64 1:3.5.17-1build2 [36.5 kB] 88s Get:105 http://ftpmaster.internal/ubuntu questing/main amd64 libxaw7 amd64 2:1.0.16-1 [207 kB] 88s Get:106 http://ftpmaster.internal/ubuntu questing/main amd64 libxfont2 amd64 1:2.0.6-1build1 [93.0 kB] 88s Get:107 http://ftpmaster.internal/ubuntu questing/main amd64 libxkbfile1 amd64 1:1.1.0-1build4 [70.0 kB] 88s Get:108 http://ftpmaster.internal/ubuntu questing/main amd64 libxrandr2 amd64 2:1.5.4-1 [19.6 kB] 88s Get:109 http://ftpmaster.internal/ubuntu questing/main amd64 libxslt1.1 amd64 1.1.43-0exp1 [163 kB] 88s Get:110 http://ftpmaster.internal/ubuntu questing/universe amd64 python-matplotlib-data all 3.10.1+dfsg1-4 [2930 kB] 88s Get:111 http://ftpmaster.internal/ubuntu questing/universe amd64 python-tables-data all 3.10.2-2build1 [49.7 kB] 88s Get:112 http://ftpmaster.internal/ubuntu questing-proposed/main amd64 python3-all amd64 3.13.4-1 [880 B] 88s Get:113 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-async-generator all 1.10-4 [17.5 kB] 89s Get:114 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-bottleneck amd64 1.4.2+ds1-2build1 [91.2 kB] 89s Get:115 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-brotli amd64 1.1.0-2build4 [367 kB] 89s Get:116 http://ftpmaster.internal/ubuntu questing/main amd64 python3-soupsieve all 2.7-1 [33.5 kB] 89s Get:117 http://ftpmaster.internal/ubuntu questing/main amd64 python3-bs4 all 4.13.4-1 [137 kB] 89s Get:118 http://ftpmaster.internal/ubuntu questing/main amd64 python3-click all 8.2.0+0.really.8.1.8-1 [80.0 kB] 89s Get:119 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-cloudpickle all 3.1.1-1 [22.4 kB] 89s Get:120 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-contourpy amd64 1.3.1-1build1 [218 kB] 89s Get:121 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-cpuinfo all 9.0.0+git20221119-3 [21.7 kB] 89s Get:122 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-cycler all 0.12.1-1 [9716 B] 89s Get:123 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-fsspec all 2025.3.0-1 [216 kB] 89s Get:124 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-toolz all 1.0.0-2 [45.0 kB] 89s Get:125 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-locket all 1.0.0-2 [5872 B] 89s Get:126 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-partd all 1.4.2-1 [15.7 kB] 89s Get:127 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-dask all 2024.12.1+dfsg-2 [875 kB] 89s Get:128 http://ftpmaster.internal/ubuntu questing/main amd64 python3-decorator all 5.2.1-2 [28.1 kB] 89s Get:129 http://ftpmaster.internal/ubuntu questing/main amd64 python3-defusedxml all 0.7.1-3 [42.2 kB] 89s Get:130 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-et-xmlfile all 2.0.0-1 [79.4 kB] 89s Get:131 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-execnet all 2.1.1-1 [33.4 kB] 89s Get:132 http://ftpmaster.internal/ubuntu questing/main amd64 python3-platformdirs all 4.3.7-1 [16.9 kB] 89s Get:133 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-fs all 2.4.16-7 [90.8 kB] 89s Get:134 http://ftpmaster.internal/ubuntu questing/main amd64 python3-lxml amd64 5.4.0-1build1 [1383 kB] 89s Get:135 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-lz4 amd64 4.4.0+dfsg-2 [26.6 kB] 89s Get:136 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-scipy amd64 1.15.3-1 [16.6 MB] 89s Get:137 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-mpmath all 1.3.0-1 [425 kB] 89s Get:138 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-sympy all 1.13.3-5 [4229 kB] 89s Get:139 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-ufolib2 all 0.17.1+dfsg1-1 [33.5 kB] 89s Get:140 http://ftpmaster.internal/ubuntu questing/universe amd64 unicode-data all 15.1.0-1 [8878 kB] 89s Get:141 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-fonttools amd64 4.55.3-2build1 [1536 kB] 89s Get:142 http://ftpmaster.internal/ubuntu questing/main amd64 python3-webencodings all 0.5.1-5 [11.5 kB] 89s Get:143 http://ftpmaster.internal/ubuntu questing/main amd64 python3-html5lib all 1.2-2 [90.6 kB] 89s Get:144 http://ftpmaster.internal/ubuntu questing/main amd64 python3-sortedcontainers all 2.4.0-2 [27.6 kB] 89s Get:145 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-hypothesis all 6.130.5-1 [341 kB] 89s Get:146 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-iniconfig all 1.1.1-2 [6024 B] 89s Get:147 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-kiwisolver amd64 1.4.7-3build1 [55.6 kB] 89s Get:148 http://ftpmaster.internal/ubuntu questing/main amd64 libopenjp2-7 amd64 2.5.3-2 [218 kB] 89s Get:149 http://ftpmaster.internal/ubuntu questing/main amd64 python3-pil amd64 11.1.0-5build1 [583 kB] 89s Get:150 http://ftpmaster.internal/ubuntu questing/main amd64 python3.13-tk amd64 3.13.4-1 [107 kB] 89s Get:151 http://ftpmaster.internal/ubuntu questing/main amd64 python3-tk amd64 3.13.3-1 [9856 B] 89s Get:152 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pil.imagetk amd64 11.1.0-5build1 [9828 B] 89s Get:153 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-matplotlib amd64 3.10.1+dfsg1-4 [18.0 MB] 90s Get:154 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-numexpr amd64 2.10.2-1build2 [131 kB] 90s Get:155 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-odf all 1.4.2-4 [79.0 kB] 90s Get:156 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-openpyxl all 3.1.5+dfsg-2 [152 kB] 90s Get:157 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pluggy all 1.5.0-1 [21.0 kB] 90s Get:158 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-py all 1.11.0-4 [72.7 kB] 90s Get:159 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pyqt5.sip amd64 12.17.0-1build1 [76.5 kB] 90s Get:160 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pyqt5 amd64 5.15.11+dfsg-2 [2725 kB] 90s Get:161 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pyreadstat amd64 1.2.8-1build1 [438 kB] 90s Get:162 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest all 8.3.5-2 [252 kB] 90s Get:163 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-asyncio all 0.25.1-1 [17.0 kB] 90s Get:164 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-forked all 1.6.0-3 [7470 B] 90s Get:165 http://ftpmaster.internal/ubuntu questing/main amd64 python3-werkzeug all 3.1.3-2 [169 kB] 90s Get:166 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-localserver all 0.9.0.post0-1 [21.9 kB] 90s Get:167 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytest-xdist all 3.6.1-1 [33.8 kB] 90s Get:168 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-pytestqt all 4.4.0-1 [32.4 kB] 90s Get:169 http://ftpmaster.internal/ubuntu questing/main amd64 python3-greenlet amd64 3.1.0-1build1 [166 kB] 90s Get:170 http://ftpmaster.internal/ubuntu questing/main amd64 python3-sqlalchemy all 2.0.38+ds1-0ubuntu2 [1215 kB] 90s Get:171 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-tables-lib amd64 3.10.2-2build1 [588 kB] 90s Get:172 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-tables all 3.10.2-2build1 [354 kB] 90s Get:173 http://ftpmaster.internal/ubuntu questing/main amd64 python3-tabulate all 0.9.0-1 [45.3 kB] 90s Get:174 http://ftpmaster.internal/ubuntu questing/main amd64 python3-tz all 2025.2-3 [1866 B] 90s Get:175 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-xarray all 2025.03.1-8 [831 kB] 90s Get:176 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-xlrd all 2.0.1-2 [83.1 kB] 90s Get:177 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-xlsxwriter all 3.1.9-2 [462 kB] 90s Get:178 http://ftpmaster.internal/ubuntu questing/universe amd64 python3-zstandard amd64 0.23.0-4 [383 kB] 90s Get:179 http://ftpmaster.internal/ubuntu questing/main amd64 tzdata-legacy all 2025b-3ubuntu1 [99.3 kB] 90s Get:180 http://ftpmaster.internal/ubuntu questing/main amd64 x11-xkb-utils amd64 7.7+9 [169 kB] 90s Get:181 http://ftpmaster.internal/ubuntu questing/universe amd64 xsel amd64 1.2.1-1 [20.5 kB] 90s Get:182 http://ftpmaster.internal/ubuntu questing/main amd64 xserver-common all 2:21.1.16-1ubuntu1 [34.4 kB] 90s Get:183 http://ftpmaster.internal/ubuntu questing/universe amd64 xvfb amd64 2:21.1.16-1ubuntu1 [975 kB] 90s Get:184 http://ftpmaster.internal/ubuntu questing/universe amd64 locales-all amd64 2.41-6ubuntu2 [11.2 MB] 91s Fetched 115 MB in 3s (41.5 MB/s) 91s Selecting previously unselected package libtcl8.6:amd64. 91s (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 ... 84210 files and directories currently installed.) 91s Preparing to unpack .../000-libtcl8.6_8.6.16+dfsg-1_amd64.deb ... 91s Unpacking libtcl8.6:amd64 (8.6.16+dfsg-1) ... 91s Selecting previously unselected package fonts-dejavu-mono. 91s Preparing to unpack .../001-fonts-dejavu-mono_2.37-8_all.deb ... 91s Unpacking fonts-dejavu-mono (2.37-8) ... 91s Selecting previously unselected package fonts-dejavu-core. 91s Preparing to unpack .../002-fonts-dejavu-core_2.37-8_all.deb ... 91s Unpacking fonts-dejavu-core (2.37-8) ... 91s Selecting previously unselected package fontconfig-config. 91s Preparing to unpack .../003-fontconfig-config_2.15.0-2.2ubuntu1_amd64.deb ... 91s Unpacking fontconfig-config (2.15.0-2.2ubuntu1) ... 91s Selecting previously unselected package libfontconfig1:amd64. 91s Preparing to unpack .../004-libfontconfig1_2.15.0-2.2ubuntu1_amd64.deb ... 91s Unpacking libfontconfig1:amd64 (2.15.0-2.2ubuntu1) ... 91s Selecting previously unselected package libxrender1:amd64. 91s Preparing to unpack .../005-libxrender1_1%3a0.9.12-1_amd64.deb ... 91s Unpacking libxrender1:amd64 (1:0.9.12-1) ... 91s Selecting previously unselected package libxft2:amd64. 91s Preparing to unpack .../006-libxft2_2.3.6-1build1_amd64.deb ... 91s Unpacking libxft2:amd64 (2.3.6-1build1) ... 91s Selecting previously unselected package x11-common. 91s Preparing to unpack .../007-x11-common_1%3a7.7+23ubuntu4_all.deb ... 91s Unpacking x11-common (1:7.7+23ubuntu4) ... 91s Selecting previously unselected package libxss1:amd64. 91s Preparing to unpack .../008-libxss1_1%3a1.2.3-1build3_amd64.deb ... 91s Unpacking libxss1:amd64 (1:1.2.3-1build3) ... 91s Selecting previously unselected package libtk8.6:amd64. 91s Preparing to unpack .../009-libtk8.6_8.6.16-1_amd64.deb ... 91s Unpacking libtk8.6:amd64 (8.6.16-1) ... 91s Selecting previously unselected package tk8.6-blt2.5. 91s Preparing to unpack .../010-tk8.6-blt2.5_2.5.3+dfsg-8_amd64.deb ... 91s Unpacking tk8.6-blt2.5 (2.5.3+dfsg-8) ... 91s Selecting previously unselected package blt. 91s Preparing to unpack .../011-blt_2.5.3+dfsg-8_amd64.deb ... 91s Unpacking blt (2.5.3+dfsg-8) ... 91s Selecting previously unselected package fontconfig. 91s Preparing to unpack .../012-fontconfig_2.15.0-2.2ubuntu1_amd64.deb ... 91s Unpacking fontconfig (2.15.0-2.2ubuntu1) ... 91s Selecting previously unselected package fonts-lyx. 91s Preparing to unpack .../013-fonts-lyx_2.4.3-1_all.deb ... 91s Unpacking fonts-lyx (2.4.3-1) ... 91s Selecting previously unselected package libaec0:amd64. 91s Preparing to unpack .../014-libaec0_1.1.3-1_amd64.deb ... 91s Unpacking libaec0:amd64 (1.1.3-1) ... 91s Selecting previously unselected package libavahi-common-data:amd64. 91s Preparing to unpack .../015-libavahi-common-data_0.8-16ubuntu2_amd64.deb ... 91s Unpacking libavahi-common-data:amd64 (0.8-16ubuntu2) ... 91s Selecting previously unselected package libavahi-common3:amd64. 91s Preparing to unpack .../016-libavahi-common3_0.8-16ubuntu2_amd64.deb ... 91s Unpacking libavahi-common3:amd64 (0.8-16ubuntu2) ... 91s Selecting previously unselected package libavahi-client3:amd64. 91s Preparing to unpack .../017-libavahi-client3_0.8-16ubuntu2_amd64.deb ... 91s Unpacking libavahi-client3:amd64 (0.8-16ubuntu2) ... 91s Selecting previously unselected package libsnappy1v5:amd64. 91s Preparing to unpack .../018-libsnappy1v5_1.2.2-1_amd64.deb ... 91s Unpacking libsnappy1v5:amd64 (1.2.2-1) ... 91s Selecting previously unselected package libblosc1:amd64. 91s Preparing to unpack .../019-libblosc1_1.21.5+ds-1build1_amd64.deb ... 91s Unpacking libblosc1:amd64 (1.21.5+ds-1build1) ... 91s Selecting previously unselected package libblosc2-4:amd64. 91s Preparing to unpack .../020-libblosc2-4_2.17.1+ds-1_amd64.deb ... 91s Unpacking libblosc2-4:amd64 (2.17.1+ds-1) ... 91s Selecting previously unselected package libcups2t64:amd64. 91s Preparing to unpack .../021-libcups2t64_2.4.12-0ubuntu1_amd64.deb ... 91s Unpacking libcups2t64:amd64 (2.4.12-0ubuntu1) ... 91s Selecting previously unselected package libdeflate0:amd64. 91s Preparing to unpack .../022-libdeflate0_1.23-2_amd64.deb ... 91s Unpacking libdeflate0:amd64 (1.23-2) ... 91s Selecting previously unselected package libdouble-conversion3:amd64. 91s Preparing to unpack .../023-libdouble-conversion3_3.3.1-1_amd64.deb ... 91s Unpacking libdouble-conversion3:amd64 (3.3.1-1) ... 91s Selecting previously unselected package libpciaccess0:amd64. 91s Preparing to unpack .../024-libpciaccess0_0.18.1-1ubuntu1_amd64.deb ... 91s Unpacking libpciaccess0:amd64 (0.18.1-1ubuntu1) ... 91s Selecting previously unselected package libdrm-intel1:amd64. 91s Preparing to unpack .../025-libdrm-intel1_2.4.124-2_amd64.deb ... 91s Unpacking libdrm-intel1:amd64 (2.4.124-2) ... 91s Selecting previously unselected package libwayland-server0:amd64. 91s Preparing to unpack .../026-libwayland-server0_1.23.1-3build1_amd64.deb ... 91s Unpacking libwayland-server0:amd64 (1.23.1-3build1) ... 91s Selecting previously unselected package libx11-xcb1:amd64. 91s Preparing to unpack .../027-libx11-xcb1_2%3a1.8.12-1_amd64.deb ... 91s Unpacking libx11-xcb1:amd64 (2:1.8.12-1) ... 92s Selecting previously unselected package libxcb-dri3-0:amd64. 92s Preparing to unpack .../028-libxcb-dri3-0_1.17.0-2_amd64.deb ... 92s Unpacking libxcb-dri3-0:amd64 (1.17.0-2) ... 92s Selecting previously unselected package libxcb-present0:amd64. 92s Preparing to unpack .../029-libxcb-present0_1.17.0-2_amd64.deb ... 92s Unpacking libxcb-present0:amd64 (1.17.0-2) ... 92s Selecting previously unselected package libxcb-randr0:amd64. 92s Preparing to unpack .../030-libxcb-randr0_1.17.0-2_amd64.deb ... 92s Unpacking libxcb-randr0:amd64 (1.17.0-2) ... 92s Selecting previously unselected package libxcb-sync1:amd64. 92s Preparing to unpack .../031-libxcb-sync1_1.17.0-2_amd64.deb ... 92s Unpacking libxcb-sync1:amd64 (1.17.0-2) ... 92s Selecting previously unselected package libxcb-xfixes0:amd64. 92s Preparing to unpack .../032-libxcb-xfixes0_1.17.0-2_amd64.deb ... 92s Unpacking libxcb-xfixes0:amd64 (1.17.0-2) ... 92s Selecting previously unselected package libxshmfence1:amd64. 92s Preparing to unpack .../033-libxshmfence1_1.3.3-1_amd64.deb ... 92s Unpacking libxshmfence1:amd64 (1.3.3-1) ... 92s Selecting previously unselected package mesa-libgallium:amd64. 92s Preparing to unpack .../034-mesa-libgallium_25.0.7-0ubuntu1_amd64.deb ... 92s Unpacking mesa-libgallium:amd64 (25.0.7-0ubuntu1) ... 92s Selecting previously unselected package libgbm1:amd64. 92s Preparing to unpack .../035-libgbm1_25.0.7-0ubuntu1_amd64.deb ... 92s Unpacking libgbm1:amd64 (25.0.7-0ubuntu1) ... 92s Selecting previously unselected package libwayland-client0:amd64. 92s Preparing to unpack .../036-libwayland-client0_1.23.1-3build1_amd64.deb ... 92s Unpacking libwayland-client0:amd64 (1.23.1-3build1) ... 92s Selecting previously unselected package libxcb-shm0:amd64. 92s Preparing to unpack .../037-libxcb-shm0_1.17.0-2_amd64.deb ... 92s Unpacking libxcb-shm0:amd64 (1.17.0-2) ... 92s Selecting previously unselected package libegl-mesa0:amd64. 92s Preparing to unpack .../038-libegl-mesa0_25.0.7-0ubuntu1_amd64.deb ... 92s Unpacking libegl-mesa0:amd64 (25.0.7-0ubuntu1) ... 92s Selecting previously unselected package libfontenc1:amd64. 92s Preparing to unpack .../039-libfontenc1_1%3a1.1.8-1build1_amd64.deb ... 92s Unpacking libfontenc1:amd64 (1:1.1.8-1build1) ... 92s Selecting previously unselected package libvulkan1:amd64. 92s Preparing to unpack .../040-libvulkan1_1.4.309.0-1_amd64.deb ... 92s Unpacking libvulkan1:amd64 (1.4.309.0-1) ... 92s Selecting previously unselected package libgl1-mesa-dri:amd64. 92s Preparing to unpack .../041-libgl1-mesa-dri_25.0.7-0ubuntu1_amd64.deb ... 92s Unpacking libgl1-mesa-dri:amd64 (25.0.7-0ubuntu1) ... 92s Selecting previously unselected package libxcb-glx0:amd64. 92s Preparing to unpack .../042-libxcb-glx0_1.17.0-2_amd64.deb ... 92s Unpacking libxcb-glx0:amd64 (1.17.0-2) ... 92s Selecting previously unselected package libxxf86vm1:amd64. 92s Preparing to unpack .../043-libxxf86vm1_1%3a1.1.4-1build4_amd64.deb ... 92s Unpacking libxxf86vm1:amd64 (1:1.1.4-1build4) ... 92s Selecting previously unselected package libglx-mesa0:amd64. 92s Preparing to unpack .../044-libglx-mesa0_25.0.7-0ubuntu1_amd64.deb ... 92s Unpacking libglx-mesa0:amd64 (25.0.7-0ubuntu1) ... 92s Selecting previously unselected package libgomp1:amd64. 92s Preparing to unpack .../045-libgomp1_15.1.0-5ubuntu1_amd64.deb ... 92s Unpacking libgomp1:amd64 (15.1.0-5ubuntu1) ... 92s Selecting previously unselected package libgraphite2-3:amd64. 92s Preparing to unpack .../046-libgraphite2-3_1.3.14-2ubuntu1_amd64.deb ... 92s Unpacking libgraphite2-3:amd64 (1.3.14-2ubuntu1) ... 92s Selecting previously unselected package libharfbuzz0b:amd64. 92s Preparing to unpack .../047-libharfbuzz0b_10.2.0-1_amd64.deb ... 92s Unpacking libharfbuzz0b:amd64 (10.2.0-1) ... 92s Selecting previously unselected package libsz2:amd64. 92s Preparing to unpack .../048-libsz2_1.1.3-1_amd64.deb ... 92s Unpacking libsz2:amd64 (1.1.3-1) ... 92s Selecting previously unselected package libhdf5-310:amd64. 92s Preparing to unpack .../049-libhdf5-310_1.14.5+repack-3build1_amd64.deb ... 92s Unpacking libhdf5-310:amd64 (1.14.5+repack-3build1) ... 92s Selecting previously unselected package libice6:amd64. 92s Preparing to unpack .../050-libice6_2%3a1.1.1-1_amd64.deb ... 92s Unpacking libice6:amd64 (2:1.1.1-1) ... 92s Selecting previously unselected package libimagequant0:amd64. 92s Preparing to unpack .../051-libimagequant0_2.18.0-1build1_amd64.deb ... 92s Unpacking libimagequant0:amd64 (2.18.0-1build1) ... 92s Selecting previously unselected package libwacom-common. 92s Preparing to unpack .../052-libwacom-common_2.14.0-1build1_all.deb ... 92s Unpacking libwacom-common (2.14.0-1build1) ... 92s Selecting previously unselected package libwacom9:amd64. 92s Preparing to unpack .../053-libwacom9_2.14.0-1build1_amd64.deb ... 92s Unpacking libwacom9:amd64 (2.14.0-1build1) ... 92s Selecting previously unselected package libinput-bin. 92s Preparing to unpack .../054-libinput-bin_1.28.1-1_amd64.deb ... 92s Unpacking libinput-bin (1.28.1-1) ... 92s Selecting previously unselected package libmtdev1t64:amd64. 92s Preparing to unpack .../055-libmtdev1t64_1.1.7-1_amd64.deb ... 92s Unpacking libmtdev1t64:amd64 (1.1.7-1) ... 92s Selecting previously unselected package libinput10:amd64. 92s Preparing to unpack .../056-libinput10_1.28.1-1_amd64.deb ... 92s Unpacking libinput10:amd64 (1.28.1-1) ... 92s Selecting previously unselected package libjpeg-turbo8:amd64. 92s Preparing to unpack .../057-libjpeg-turbo8_2.1.5-3ubuntu2_amd64.deb ... 92s Unpacking libjpeg-turbo8:amd64 (2.1.5-3ubuntu2) ... 92s Selecting previously unselected package libjpeg8:amd64. 92s Preparing to unpack .../058-libjpeg8_8c-2ubuntu11_amd64.deb ... 92s Unpacking libjpeg8:amd64 (8c-2ubuntu11) ... 92s Selecting previously unselected package libjs-jquery. 92s Preparing to unpack .../059-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 92s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 92s Selecting previously unselected package libjs-jquery-ui. 92s Preparing to unpack .../060-libjs-jquery-ui_1.13.2+dfsg-1_all.deb ... 92s Unpacking libjs-jquery-ui (1.13.2+dfsg-1) ... 92s Selecting previously unselected package liblcms2-2:amd64. 92s Preparing to unpack .../061-liblcms2-2_2.16-2_amd64.deb ... 92s Unpacking liblcms2-2:amd64 (2.16-2) ... 92s Selecting previously unselected package liblerc4:amd64. 92s Preparing to unpack .../062-liblerc4_4.0.0+ds-5ubuntu1_amd64.deb ... 92s Unpacking liblerc4:amd64 (4.0.0+ds-5ubuntu1) ... 92s Selecting previously unselected package libmd4c0:amd64. 92s Preparing to unpack .../063-libmd4c0_0.5.2-2_amd64.deb ... 92s Unpacking libmd4c0:amd64 (0.5.2-2) ... 92s Selecting previously unselected package libpcre2-16-0:amd64. 92s Preparing to unpack .../064-libpcre2-16-0_10.45-1_amd64.deb ... 92s Unpacking libpcre2-16-0:amd64 (10.45-1) ... 93s Selecting previously unselected package libpixman-1-0:amd64. 93s Preparing to unpack .../065-libpixman-1-0_0.44.0-3_amd64.deb ... 93s Unpacking libpixman-1-0:amd64 (0.44.0-3) ... 93s Selecting previously unselected package libqhull-r8.0:amd64. 93s Preparing to unpack .../066-libqhull-r8.0_2020.2-6build1_amd64.deb ... 93s Unpacking libqhull-r8.0:amd64 (2020.2-6build1) ... 93s Selecting previously unselected package libqt5core5t64:amd64. 93s Preparing to unpack .../067-libqt5core5t64_5.15.15+dfsg-5ubuntu1_amd64.deb ... 93s Unpacking libqt5core5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 93s Selecting previously unselected package libqt5dbus5t64:amd64. 93s Preparing to unpack .../068-libqt5dbus5t64_5.15.15+dfsg-5ubuntu1_amd64.deb ... 93s Unpacking libqt5dbus5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 93s Selecting previously unselected package libglvnd0:amd64. 93s Preparing to unpack .../069-libglvnd0_1.7.0-1build1_amd64.deb ... 93s Unpacking libglvnd0:amd64 (1.7.0-1build1) ... 93s Selecting previously unselected package libegl1:amd64. 93s Preparing to unpack .../070-libegl1_1.7.0-1build1_amd64.deb ... 93s Unpacking libegl1:amd64 (1.7.0-1build1) ... 93s Selecting previously unselected package libglx0:amd64. 93s Preparing to unpack .../071-libglx0_1.7.0-1build1_amd64.deb ... 93s Unpacking libglx0:amd64 (1.7.0-1build1) ... 93s Selecting previously unselected package libgl1:amd64. 93s Preparing to unpack .../072-libgl1_1.7.0-1build1_amd64.deb ... 93s Unpacking libgl1:amd64 (1.7.0-1build1) ... 93s Selecting previously unselected package libqt5network5t64:amd64. 93s Preparing to unpack .../073-libqt5network5t64_5.15.15+dfsg-5ubuntu1_amd64.deb ... 93s Unpacking libqt5network5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 93s Selecting previously unselected package libsm6:amd64. 93s Preparing to unpack .../074-libsm6_2%3a1.2.6-1_amd64.deb ... 93s Unpacking libsm6:amd64 (2:1.2.6-1) ... 93s Selecting previously unselected package libxcb-icccm4:amd64. 93s Preparing to unpack .../075-libxcb-icccm4_0.4.2-1_amd64.deb ... 93s Unpacking libxcb-icccm4:amd64 (0.4.2-1) ... 93s Selecting previously unselected package libxcb-util1:amd64. 93s Preparing to unpack .../076-libxcb-util1_0.4.1-1_amd64.deb ... 93s Unpacking libxcb-util1:amd64 (0.4.1-1) ... 93s Selecting previously unselected package libxcb-image0:amd64. 93s Preparing to unpack .../077-libxcb-image0_0.4.0-2build1_amd64.deb ... 93s Unpacking libxcb-image0:amd64 (0.4.0-2build1) ... 93s Selecting previously unselected package libxcb-keysyms1:amd64. 93s Preparing to unpack .../078-libxcb-keysyms1_0.4.1-1_amd64.deb ... 93s Unpacking libxcb-keysyms1:amd64 (0.4.1-1) ... 93s Selecting previously unselected package libxcb-render0:amd64. 93s Preparing to unpack .../079-libxcb-render0_1.17.0-2_amd64.deb ... 93s Unpacking libxcb-render0:amd64 (1.17.0-2) ... 93s Selecting previously unselected package libxcb-render-util0:amd64. 93s Preparing to unpack .../080-libxcb-render-util0_0.3.10-1_amd64.deb ... 93s Unpacking libxcb-render-util0:amd64 (0.3.10-1) ... 93s Selecting previously unselected package libxcb-shape0:amd64. 93s Preparing to unpack .../081-libxcb-shape0_1.17.0-2_amd64.deb ... 93s Unpacking libxcb-shape0:amd64 (1.17.0-2) ... 93s Selecting previously unselected package libxcb-xinerama0:amd64. 93s Preparing to unpack .../082-libxcb-xinerama0_1.17.0-2_amd64.deb ... 93s Unpacking libxcb-xinerama0:amd64 (1.17.0-2) ... 93s Selecting previously unselected package libxcb-xinput0:amd64. 93s Preparing to unpack .../083-libxcb-xinput0_1.17.0-2_amd64.deb ... 93s Unpacking libxcb-xinput0:amd64 (1.17.0-2) ... 93s Selecting previously unselected package libxcb-xkb1:amd64. 93s Preparing to unpack .../084-libxcb-xkb1_1.17.0-2_amd64.deb ... 93s Unpacking libxcb-xkb1:amd64 (1.17.0-2) ... 93s Selecting previously unselected package libxkbcommon-x11-0:amd64. 93s Preparing to unpack .../085-libxkbcommon-x11-0_1.7.0-2ubuntu1_amd64.deb ... 93s Unpacking libxkbcommon-x11-0:amd64 (1.7.0-2ubuntu1) ... 93s Selecting previously unselected package libqt5gui5t64:amd64. 93s Preparing to unpack .../086-libqt5gui5t64_5.15.15+dfsg-5ubuntu1_amd64.deb ... 93s Unpacking libqt5gui5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 93s Selecting previously unselected package libqt5widgets5t64:amd64. 93s Preparing to unpack .../087-libqt5widgets5t64_5.15.15+dfsg-5ubuntu1_amd64.deb ... 93s Unpacking libqt5widgets5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 93s Selecting previously unselected package libqt5xml5t64:amd64. 93s Preparing to unpack .../088-libqt5xml5t64_5.15.15+dfsg-5ubuntu1_amd64.deb ... 93s Unpacking libqt5xml5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 93s Selecting previously unselected package libqt5designer5:amd64. 93s Preparing to unpack .../089-libqt5designer5_5.15.15-6build1_amd64.deb ... 93s Unpacking libqt5designer5:amd64 (5.15.15-6build1) ... 93s Selecting previously unselected package libqt5sql5t64:amd64. 93s Preparing to unpack .../090-libqt5sql5t64_5.15.15+dfsg-5ubuntu1_amd64.deb ... 93s Unpacking libqt5sql5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 93s Selecting previously unselected package libqt5help5:amd64. 93s Preparing to unpack .../091-libqt5help5_5.15.15-6build1_amd64.deb ... 93s Unpacking libqt5help5:amd64 (5.15.15-6build1) ... 93s Selecting previously unselected package libqt5printsupport5t64:amd64. 93s Preparing to unpack .../092-libqt5printsupport5t64_5.15.15+dfsg-5ubuntu1_amd64.deb ... 93s Unpacking libqt5printsupport5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 93s Selecting previously unselected package libqt5test5t64:amd64. 93s Preparing to unpack .../093-libqt5test5t64_5.15.15+dfsg-5ubuntu1_amd64.deb ... 93s Unpacking libqt5test5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 93s Selecting previously unselected package libraqm0:amd64. 93s Preparing to unpack .../094-libraqm0_0.10.2-1_amd64.deb ... 93s Unpacking libraqm0:amd64 (0.10.2-1) ... 93s Selecting previously unselected package libsharpyuv0:amd64. 93s Preparing to unpack .../095-libsharpyuv0_1.5.0-0.1_amd64.deb ... 93s Unpacking libsharpyuv0:amd64 (1.5.0-0.1) ... 93s Selecting previously unselected package libjbig0:amd64. 93s Preparing to unpack .../096-libjbig0_2.1-6.1ubuntu2_amd64.deb ... 93s Unpacking libjbig0:amd64 (2.1-6.1ubuntu2) ... 93s Selecting previously unselected package libwebp7:amd64. 93s Preparing to unpack .../097-libwebp7_1.5.0-0.1_amd64.deb ... 93s Unpacking libwebp7:amd64 (1.5.0-0.1) ... 93s Selecting previously unselected package libtiff6:amd64. 93s Preparing to unpack .../098-libtiff6_4.7.0-3ubuntu1_amd64.deb ... 93s Unpacking libtiff6:amd64 (4.7.0-3ubuntu1) ... 93s Selecting previously unselected package libwebpdemux2:amd64. 93s Preparing to unpack .../099-libwebpdemux2_1.5.0-0.1_amd64.deb ... 93s Unpacking libwebpdemux2:amd64 (1.5.0-0.1) ... 93s Selecting previously unselected package libwebpmux3:amd64. 93s Preparing to unpack .../100-libwebpmux3_1.5.0-0.1_amd64.deb ... 93s Unpacking libwebpmux3:amd64 (1.5.0-0.1) ... 93s Selecting previously unselected package libxt6t64:amd64. 93s Preparing to unpack .../101-libxt6t64_1%3a1.2.1-1.2build1_amd64.deb ... 93s Unpacking libxt6t64:amd64 (1:1.2.1-1.2build1) ... 93s Selecting previously unselected package libxmu6:amd64. 93s Preparing to unpack .../102-libxmu6_2%3a1.1.3-3build2_amd64.deb ... 93s Unpacking libxmu6:amd64 (2:1.1.3-3build2) ... 93s Selecting previously unselected package libxpm4:amd64. 93s Preparing to unpack .../103-libxpm4_1%3a3.5.17-1build2_amd64.deb ... 93s Unpacking libxpm4:amd64 (1:3.5.17-1build2) ... 93s Selecting previously unselected package libxaw7:amd64. 93s Preparing to unpack .../104-libxaw7_2%3a1.0.16-1_amd64.deb ... 93s Unpacking libxaw7:amd64 (2:1.0.16-1) ... 93s Selecting previously unselected package libxfont2:amd64. 93s Preparing to unpack .../105-libxfont2_1%3a2.0.6-1build1_amd64.deb ... 93s Unpacking libxfont2:amd64 (1:2.0.6-1build1) ... 94s Selecting previously unselected package libxkbfile1:amd64. 94s Preparing to unpack .../106-libxkbfile1_1%3a1.1.0-1build4_amd64.deb ... 94s Unpacking libxkbfile1:amd64 (1:1.1.0-1build4) ... 94s Selecting previously unselected package libxrandr2:amd64. 94s Preparing to unpack .../107-libxrandr2_2%3a1.5.4-1_amd64.deb ... 94s Unpacking libxrandr2:amd64 (2:1.5.4-1) ... 94s Selecting previously unselected package libxslt1.1:amd64. 94s Preparing to unpack .../108-libxslt1.1_1.1.43-0exp1_amd64.deb ... 94s Unpacking libxslt1.1:amd64 (1.1.43-0exp1) ... 94s Selecting previously unselected package python-matplotlib-data. 94s Preparing to unpack .../109-python-matplotlib-data_3.10.1+dfsg1-4_all.deb ... 94s Unpacking python-matplotlib-data (3.10.1+dfsg1-4) ... 94s Selecting previously unselected package python-tables-data. 94s Preparing to unpack .../110-python-tables-data_3.10.2-2build1_all.deb ... 94s Unpacking python-tables-data (3.10.2-2build1) ... 94s Selecting previously unselected package python3-all. 94s Preparing to unpack .../111-python3-all_3.13.4-1_amd64.deb ... 94s Unpacking python3-all (3.13.4-1) ... 94s Selecting previously unselected package python3-async-generator. 94s Preparing to unpack .../112-python3-async-generator_1.10-4_all.deb ... 94s Unpacking python3-async-generator (1.10-4) ... 94s Selecting previously unselected package python3-bottleneck. 94s Preparing to unpack .../113-python3-bottleneck_1.4.2+ds1-2build1_amd64.deb ... 94s Unpacking python3-bottleneck (1.4.2+ds1-2build1) ... 94s Selecting previously unselected package python3-brotli. 94s Preparing to unpack .../114-python3-brotli_1.1.0-2build4_amd64.deb ... 94s Unpacking python3-brotli (1.1.0-2build4) ... 94s Selecting previously unselected package python3-soupsieve. 94s Preparing to unpack .../115-python3-soupsieve_2.7-1_all.deb ... 94s Unpacking python3-soupsieve (2.7-1) ... 94s Selecting previously unselected package python3-bs4. 94s Preparing to unpack .../116-python3-bs4_4.13.4-1_all.deb ... 94s Unpacking python3-bs4 (4.13.4-1) ... 94s Selecting previously unselected package python3-click. 94s Preparing to unpack .../117-python3-click_8.2.0+0.really.8.1.8-1_all.deb ... 94s Unpacking python3-click (8.2.0+0.really.8.1.8-1) ... 94s Selecting previously unselected package python3-cloudpickle. 94s Preparing to unpack .../118-python3-cloudpickle_3.1.1-1_all.deb ... 94s Unpacking python3-cloudpickle (3.1.1-1) ... 94s Selecting previously unselected package python3-contourpy. 94s Preparing to unpack .../119-python3-contourpy_1.3.1-1build1_amd64.deb ... 94s Unpacking python3-contourpy (1.3.1-1build1) ... 94s Selecting previously unselected package python3-cpuinfo. 94s Preparing to unpack .../120-python3-cpuinfo_9.0.0+git20221119-3_all.deb ... 94s Unpacking python3-cpuinfo (9.0.0+git20221119-3) ... 94s Selecting previously unselected package python3-cycler. 94s Preparing to unpack .../121-python3-cycler_0.12.1-1_all.deb ... 94s Unpacking python3-cycler (0.12.1-1) ... 94s Selecting previously unselected package python3-fsspec. 94s Preparing to unpack .../122-python3-fsspec_2025.3.0-1_all.deb ... 94s Unpacking python3-fsspec (2025.3.0-1) ... 94s Selecting previously unselected package python3-toolz. 94s Preparing to unpack .../123-python3-toolz_1.0.0-2_all.deb ... 94s Unpacking python3-toolz (1.0.0-2) ... 94s Selecting previously unselected package python3-locket. 94s Preparing to unpack .../124-python3-locket_1.0.0-2_all.deb ... 94s Unpacking python3-locket (1.0.0-2) ... 94s Selecting previously unselected package python3-partd. 94s Preparing to unpack .../125-python3-partd_1.4.2-1_all.deb ... 94s Unpacking python3-partd (1.4.2-1) ... 94s Selecting previously unselected package python3-dask. 94s Preparing to unpack .../126-python3-dask_2024.12.1+dfsg-2_all.deb ... 94s Unpacking python3-dask (2024.12.1+dfsg-2) ... 94s Selecting previously unselected package python3-decorator. 94s Preparing to unpack .../127-python3-decorator_5.2.1-2_all.deb ... 94s Unpacking python3-decorator (5.2.1-2) ... 94s Selecting previously unselected package python3-defusedxml. 94s Preparing to unpack .../128-python3-defusedxml_0.7.1-3_all.deb ... 94s Unpacking python3-defusedxml (0.7.1-3) ... 94s Selecting previously unselected package python3-et-xmlfile. 94s Preparing to unpack .../129-python3-et-xmlfile_2.0.0-1_all.deb ... 94s Unpacking python3-et-xmlfile (2.0.0-1) ... 94s Selecting previously unselected package python3-execnet. 94s Preparing to unpack .../130-python3-execnet_2.1.1-1_all.deb ... 94s Unpacking python3-execnet (2.1.1-1) ... 94s Selecting previously unselected package python3-platformdirs. 94s Preparing to unpack .../131-python3-platformdirs_4.3.7-1_all.deb ... 94s Unpacking python3-platformdirs (4.3.7-1) ... 94s Selecting previously unselected package python3-fs. 94s Preparing to unpack .../132-python3-fs_2.4.16-7_all.deb ... 94s Unpacking python3-fs (2.4.16-7) ... 94s Selecting previously unselected package python3-lxml:amd64. 94s Preparing to unpack .../133-python3-lxml_5.4.0-1build1_amd64.deb ... 94s Unpacking python3-lxml:amd64 (5.4.0-1build1) ... 94s Selecting previously unselected package python3-lz4. 94s Preparing to unpack .../134-python3-lz4_4.4.0+dfsg-2_amd64.deb ... 94s Unpacking python3-lz4 (4.4.0+dfsg-2) ... 94s Selecting previously unselected package python3-scipy. 94s Preparing to unpack .../135-python3-scipy_1.15.3-1_amd64.deb ... 94s Unpacking python3-scipy (1.15.3-1) ... 95s Selecting previously unselected package python3-mpmath. 95s Preparing to unpack .../136-python3-mpmath_1.3.0-1_all.deb ... 95s Unpacking python3-mpmath (1.3.0-1) ... 95s Selecting previously unselected package python3-sympy. 95s Preparing to unpack .../137-python3-sympy_1.13.3-5_all.deb ... 95s Unpacking python3-sympy (1.13.3-5) ... 95s Selecting previously unselected package python3-ufolib2. 95s Preparing to unpack .../138-python3-ufolib2_0.17.1+dfsg1-1_all.deb ... 95s Unpacking python3-ufolib2 (0.17.1+dfsg1-1) ... 95s Selecting previously unselected package unicode-data. 95s Preparing to unpack .../139-unicode-data_15.1.0-1_all.deb ... 95s Unpacking unicode-data (15.1.0-1) ... 95s Selecting previously unselected package python3-fonttools. 95s Preparing to unpack .../140-python3-fonttools_4.55.3-2build1_amd64.deb ... 95s Unpacking python3-fonttools (4.55.3-2build1) ... 95s Selecting previously unselected package python3-webencodings. 95s Preparing to unpack .../141-python3-webencodings_0.5.1-5_all.deb ... 95s Unpacking python3-webencodings (0.5.1-5) ... 95s Selecting previously unselected package python3-html5lib. 95s Preparing to unpack .../142-python3-html5lib_1.2-2_all.deb ... 95s Unpacking python3-html5lib (1.2-2) ... 95s Selecting previously unselected package python3-sortedcontainers. 95s Preparing to unpack .../143-python3-sortedcontainers_2.4.0-2_all.deb ... 95s Unpacking python3-sortedcontainers (2.4.0-2) ... 95s Selecting previously unselected package python3-hypothesis. 95s Preparing to unpack .../144-python3-hypothesis_6.130.5-1_all.deb ... 95s Unpacking python3-hypothesis (6.130.5-1) ... 95s Selecting previously unselected package python3-iniconfig. 95s Preparing to unpack .../145-python3-iniconfig_1.1.1-2_all.deb ... 95s Unpacking python3-iniconfig (1.1.1-2) ... 95s Selecting previously unselected package python3-kiwisolver. 95s Preparing to unpack .../146-python3-kiwisolver_1.4.7-3build1_amd64.deb ... 95s Unpacking python3-kiwisolver (1.4.7-3build1) ... 95s Selecting previously unselected package libopenjp2-7:amd64. 95s Preparing to unpack .../147-libopenjp2-7_2.5.3-2_amd64.deb ... 95s Unpacking libopenjp2-7:amd64 (2.5.3-2) ... 95s Selecting previously unselected package python3-pil:amd64. 95s Preparing to unpack .../148-python3-pil_11.1.0-5build1_amd64.deb ... 95s Unpacking python3-pil:amd64 (11.1.0-5build1) ... 95s Selecting previously unselected package python3.13-tk. 95s Preparing to unpack .../149-python3.13-tk_3.13.4-1_amd64.deb ... 95s Unpacking python3.13-tk (3.13.4-1) ... 95s Selecting previously unselected package python3-tk:amd64. 95s Preparing to unpack .../150-python3-tk_3.13.3-1_amd64.deb ... 95s Unpacking python3-tk:amd64 (3.13.3-1) ... 95s Selecting previously unselected package python3-pil.imagetk:amd64. 95s Preparing to unpack .../151-python3-pil.imagetk_11.1.0-5build1_amd64.deb ... 95s Unpacking python3-pil.imagetk:amd64 (11.1.0-5build1) ... 95s Selecting previously unselected package python3-matplotlib. 95s Preparing to unpack .../152-python3-matplotlib_3.10.1+dfsg1-4_amd64.deb ... 95s Unpacking python3-matplotlib (3.10.1+dfsg1-4) ... 96s Selecting previously unselected package python3-numexpr. 96s Preparing to unpack .../153-python3-numexpr_2.10.2-1build2_amd64.deb ... 96s Unpacking python3-numexpr (2.10.2-1build2) ... 96s Selecting previously unselected package python3-odf. 96s Preparing to unpack .../154-python3-odf_1.4.2-4_all.deb ... 96s Unpacking python3-odf (1.4.2-4) ... 96s Selecting previously unselected package python3-openpyxl. 96s Preparing to unpack .../155-python3-openpyxl_3.1.5+dfsg-2_all.deb ... 96s Unpacking python3-openpyxl (3.1.5+dfsg-2) ... 96s Selecting previously unselected package python3-pluggy. 96s Preparing to unpack .../156-python3-pluggy_1.5.0-1_all.deb ... 96s Unpacking python3-pluggy (1.5.0-1) ... 96s Selecting previously unselected package python3-py. 96s Preparing to unpack .../157-python3-py_1.11.0-4_all.deb ... 96s Unpacking python3-py (1.11.0-4) ... 96s Selecting previously unselected package python3-pyqt5.sip. 96s Preparing to unpack .../158-python3-pyqt5.sip_12.17.0-1build1_amd64.deb ... 96s Unpacking python3-pyqt5.sip (12.17.0-1build1) ... 96s Selecting previously unselected package python3-pyqt5. 96s Preparing to unpack .../159-python3-pyqt5_5.15.11+dfsg-2_amd64.deb ... 96s Unpacking python3-pyqt5 (5.15.11+dfsg-2) ... 96s Selecting previously unselected package python3-pyreadstat. 96s Preparing to unpack .../160-python3-pyreadstat_1.2.8-1build1_amd64.deb ... 96s Unpacking python3-pyreadstat (1.2.8-1build1) ... 96s Selecting previously unselected package python3-pytest. 96s Preparing to unpack .../161-python3-pytest_8.3.5-2_all.deb ... 96s Unpacking python3-pytest (8.3.5-2) ... 96s Selecting previously unselected package python3-pytest-asyncio. 96s Preparing to unpack .../162-python3-pytest-asyncio_0.25.1-1_all.deb ... 96s Unpacking python3-pytest-asyncio (0.25.1-1) ... 96s Selecting previously unselected package python3-pytest-forked. 96s Preparing to unpack .../163-python3-pytest-forked_1.6.0-3_all.deb ... 96s Unpacking python3-pytest-forked (1.6.0-3) ... 96s Selecting previously unselected package python3-werkzeug. 96s Preparing to unpack .../164-python3-werkzeug_3.1.3-2_all.deb ... 96s Unpacking python3-werkzeug (3.1.3-2) ... 96s Selecting previously unselected package python3-pytest-localserver. 96s Preparing to unpack .../165-python3-pytest-localserver_0.9.0.post0-1_all.deb ... 96s Unpacking python3-pytest-localserver (0.9.0.post0-1) ... 96s Selecting previously unselected package python3-pytest-xdist. 96s Preparing to unpack .../166-python3-pytest-xdist_3.6.1-1_all.deb ... 96s Unpacking python3-pytest-xdist (3.6.1-1) ... 96s Selecting previously unselected package python3-pytestqt. 96s Preparing to unpack .../167-python3-pytestqt_4.4.0-1_all.deb ... 96s Unpacking python3-pytestqt (4.4.0-1) ... 96s Selecting previously unselected package python3-greenlet. 96s Preparing to unpack .../168-python3-greenlet_3.1.0-1build1_amd64.deb ... 96s Unpacking python3-greenlet (3.1.0-1build1) ... 96s Selecting previously unselected package python3-sqlalchemy. 96s Preparing to unpack .../169-python3-sqlalchemy_2.0.38+ds1-0ubuntu2_all.deb ... 96s Unpacking python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 96s Selecting previously unselected package python3-tables-lib. 96s Preparing to unpack .../170-python3-tables-lib_3.10.2-2build1_amd64.deb ... 96s Unpacking python3-tables-lib (3.10.2-2build1) ... 96s Selecting previously unselected package python3-tables. 96s Preparing to unpack .../171-python3-tables_3.10.2-2build1_all.deb ... 96s Unpacking python3-tables (3.10.2-2build1) ... 96s Selecting previously unselected package python3-tabulate. 96s Preparing to unpack .../172-python3-tabulate_0.9.0-1_all.deb ... 96s Unpacking python3-tabulate (0.9.0-1) ... 96s Selecting previously unselected package python3-tz. 96s Preparing to unpack .../173-python3-tz_2025.2-3_all.deb ... 96s Unpacking python3-tz (2025.2-3) ... 96s Selecting previously unselected package python3-xarray. 96s Preparing to unpack .../174-python3-xarray_2025.03.1-8_all.deb ... 96s Unpacking python3-xarray (2025.03.1-8) ... 96s Selecting previously unselected package python3-xlrd. 96s Preparing to unpack .../175-python3-xlrd_2.0.1-2_all.deb ... 96s Unpacking python3-xlrd (2.0.1-2) ... 96s Selecting previously unselected package python3-xlsxwriter. 96s Preparing to unpack .../176-python3-xlsxwriter_3.1.9-2_all.deb ... 96s Unpacking python3-xlsxwriter (3.1.9-2) ... 96s Selecting previously unselected package python3-zstandard. 96s Preparing to unpack .../177-python3-zstandard_0.23.0-4_amd64.deb ... 96s Unpacking python3-zstandard (0.23.0-4) ... 96s Selecting previously unselected package tzdata-legacy. 96s Preparing to unpack .../178-tzdata-legacy_2025b-3ubuntu1_all.deb ... 96s Unpacking tzdata-legacy (2025b-3ubuntu1) ... 96s Selecting previously unselected package x11-xkb-utils. 96s Preparing to unpack .../179-x11-xkb-utils_7.7+9_amd64.deb ... 96s Unpacking x11-xkb-utils (7.7+9) ... 97s Selecting previously unselected package xsel. 97s Preparing to unpack .../180-xsel_1.2.1-1_amd64.deb ... 97s Unpacking xsel (1.2.1-1) ... 97s Selecting previously unselected package xserver-common. 97s Preparing to unpack .../181-xserver-common_2%3a21.1.16-1ubuntu1_all.deb ... 97s Unpacking xserver-common (2:21.1.16-1ubuntu1) ... 97s Selecting previously unselected package xvfb. 97s Preparing to unpack .../182-xvfb_2%3a21.1.16-1ubuntu1_amd64.deb ... 97s Unpacking xvfb (2:21.1.16-1ubuntu1) ... 97s Selecting previously unselected package locales-all. 97s Preparing to unpack .../183-locales-all_2.41-6ubuntu2_amd64.deb ... 97s Unpacking locales-all (2.41-6ubuntu2) ... 98s Setting up libgraphite2-3:amd64 (1.3.14-2ubuntu1) ... 98s Setting up xsel (1.2.1-1) ... 98s Setting up libxcb-dri3-0:amd64 (1.17.0-2) ... 98s Setting up liblcms2-2:amd64 (2.16-2) ... 98s Setting up python3-iniconfig (1.1.1-2) ... 98s Setting up libpixman-1-0:amd64 (0.44.0-3) ... 98s Setting up libsharpyuv0:amd64 (1.5.0-0.1) ... 98s Setting up libwayland-server0:amd64 (1.23.1-3build1) ... 98s Setting up libx11-xcb1:amd64 (2:1.8.12-1) ... 98s Setting up libpciaccess0:amd64 (0.18.1-1ubuntu1) ... 98s Setting up libdouble-conversion3:amd64 (3.3.1-1) ... 98s Setting up libxcb-xfixes0:amd64 (1.17.0-2) ... 98s Setting up liblerc4:amd64 (4.0.0+ds-5ubuntu1) ... 98s Setting up libxpm4:amd64 (1:3.5.17-1build2) ... 98s Setting up python3-async-generator (1.10-4) ... 98s Setting up libxcb-xinput0:amd64 (1.17.0-2) ... 98s Setting up libxrender1:amd64 (1:0.9.12-1) ... 98s Setting up python3-py (1.11.0-4) ... 98s Setting up python3-lz4 (4.4.0+dfsg-2) ... 98s Setting up libxcb-render0:amd64 (1.17.0-2) ... 98s Setting up python3-defusedxml (0.7.1-3) ... 98s Setting up libglvnd0:amd64 (1.7.0-1build1) ... 98s Setting up fonts-lyx (2.4.3-1) ... 98s Setting up libxcb-glx0:amd64 (1.17.0-2) ... 98s Setting up python3-fsspec (2025.3.0-1) ... 98s Setting up python3-xarray (2025.03.1-8) ... 99s Setting up libdrm-intel1:amd64 (2.4.124-2) ... 99s Setting up libxcb-keysyms1:amd64 (0.4.1-1) ... 99s Setting up libxcb-shape0:amd64 (1.17.0-2) ... 99s Setting up x11-common (1:7.7+23ubuntu4) ... 100s Setting up libdeflate0:amd64 (1.23-2) ... 100s Setting up python3-tabulate (0.9.0-1) ... 100s Setting up libqhull-r8.0:amd64 (2020.2-6build1) ... 100s Setting up libxcb-render-util0:amd64 (0.3.10-1) ... 100s Setting up python3-all (3.13.4-1) ... 100s Setting up libxcb-shm0:amd64 (1.17.0-2) ... 100s Setting up libxcb-icccm4:amd64 (0.4.2-1) ... 100s Setting up python3-sortedcontainers (2.4.0-2) ... 100s Setting up libgomp1:amd64 (15.1.0-5ubuntu1) ... 100s Setting up python3-click (8.2.0+0.really.8.1.8-1) ... 100s Setting up libjbig0:amd64 (2.1-6.1ubuntu2) ... 100s Setting up python3-webencodings (0.5.1-5) ... 100s Setting up python3-pyreadstat (1.2.8-1build1) ... 100s Setting up locales-all (2.41-6ubuntu2) ... 100s Setting up libpcre2-16-0:amd64 (10.45-1) ... 100s Setting up libaec0:amd64 (1.1.3-1) ... 100s Setting up python3-platformdirs (4.3.7-1) ... 100s Setting up tzdata-legacy (2025b-3ubuntu1) ... 100s Setting up python3-tz (2025.2-3) ... 100s Setting up libxcb-util1:amd64 (0.4.1-1) ... 100s Setting up libxxf86vm1:amd64 (1:1.1.4-1build4) ... 100s Setting up python3-cloudpickle (3.1.1-1) ... 100s Setting up libsnappy1v5:amd64 (1.2.2-1) ... 100s Setting up libxcb-xkb1:amd64 (1.17.0-2) ... 100s Setting up libxcb-image0:amd64 (0.4.0-2build1) ... 100s Setting up python3-fs (2.4.16-7) ... 100s Setting up libxcb-present0:amd64 (1.17.0-2) ... 100s Setting up unicode-data (15.1.0-1) ... 100s Setting up libqt5core5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 100s Setting up python3-decorator (5.2.1-2) ... 101s Setting up libblosc2-4:amd64 (2.17.1+ds-1) ... 101s Setting up libfontenc1:amd64 (1:1.1.8-1build1) ... 101s Setting up python3-zstandard (0.23.0-4) ... 101s Setting up libxcb-xinerama0:amd64 (1.17.0-2) ... 101s Setting up python3-xlsxwriter (3.1.9-2) ... 101s Setting up libxcb-sync1:amd64 (1.17.0-2) ... 101s Setting up python3-werkzeug (3.1.3-2) ... 101s Setting up python3-brotli (1.1.0-2build4) ... 101s Setting up libavahi-common-data:amd64 (0.8-16ubuntu2) ... 101s Setting up python3-greenlet (3.1.0-1build1) ... 101s Setting up python3-cycler (0.12.1-1) ... 101s Setting up libimagequant0:amd64 (2.18.0-1build1) ... 101s Setting up libxkbcommon-x11-0:amd64 (1.7.0-2ubuntu1) ... 101s Setting up fonts-dejavu-mono (2.37-8) ... 101s Setting up python3-kiwisolver (1.4.7-3build1) ... 101s Setting up python3-bottleneck (1.4.2+ds1-2build1) ... 101s Setting up libxrandr2:amd64 (2:1.5.4-1) ... 101s Setting up libtcl8.6:amd64 (8.6.16+dfsg-1) ... 101s Setting up fonts-dejavu-core (2.37-8) ... 101s Setting up python3-numexpr (2.10.2-1build2) ... 102s Setting up libjpeg-turbo8:amd64 (2.1.5-3ubuntu2) ... 102s Setting up python3-cpuinfo (9.0.0+git20221119-3) ... 102s Setting up python3-html5lib (1.2-2) ... 102s Setting up libvulkan1:amd64 (1.4.309.0-1) ... 102s Setting up python3-pluggy (1.5.0-1) ... 102s Setting up libwebp7:amd64 (1.5.0-0.1) ... 102s Setting up python3-pyqt5.sip (12.17.0-1build1) ... 102s Setting up libmtdev1t64:amd64 (1.1.7-1) ... 102s Setting up libxshmfence1:amd64 (1.3.3-1) ... 102s Setting up libxcb-randr0:amd64 (1.17.0-2) ... 102s Setting up libxslt1.1:amd64 (1.1.43-0exp1) ... 102s Setting up libblosc1:amd64 (1.21.5+ds-1build1) ... 102s Setting up python3-et-xmlfile (2.0.0-1) ... 102s Setting up libqt5sql5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 102s Setting up libmd4c0:amd64 (0.5.2-2) ... 102s Setting up python3-xlrd (2.0.1-2) ... 102s Setting up libopenjp2-7:amd64 (2.5.3-2) ... 102s Setting up python3-toolz (1.0.0-2) ... 102s Setting up libharfbuzz0b:amd64 (10.2.0-1) ... 102s Setting up python3-contourpy (1.3.1-1build1) ... 102s Setting up libxss1:amd64 (1:1.2.3-1build3) ... 102s Setting up libxkbfile1:amd64 (1:1.1.0-1build4) ... 102s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 102s Setting up python3-mpmath (1.3.0-1) ... 103s Setting up python3-execnet (2.1.1-1) ... 103s Setting up python-matplotlib-data (3.10.1+dfsg1-4) ... 103s Setting up libwebpmux3:amd64 (1.5.0-0.1) ... 103s Setting up python3-locket (1.0.0-2) ... 103s Setting up libxfont2:amd64 (1:2.0.6-1build1) ... 103s Setting up python3-soupsieve (2.7-1) ... 103s Setting up python-tables-data (3.10.2-2build1) ... 103s Setting up libsz2:amd64 (1.1.3-1) ... 103s Setting up python3-odf (1.4.2-4) ... 103s Setting up libwacom-common (2.14.0-1build1) ... 103s Setting up libwayland-client0:amd64 (1.23.1-3build1) ... 103s Setting up libjpeg8:amd64 (8c-2ubuntu11) ... 103s Setting up python3-partd (1.4.2-1) ... 103s Setting up python3-sympy (1.13.3-5) ... 108s Setting up libice6:amd64 (2:1.1.1-1) ... 108s Setting up mesa-libgallium:amd64 (25.0.7-0ubuntu1) ... 108s Setting up libqt5dbus5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 108s Setting up python3-scipy (1.15.3-1) ... 110s Setting up libgbm1:amd64 (25.0.7-0ubuntu1) ... 110s Setting up libwacom9:amd64 (2.14.0-1build1) ... 110s Setting up fontconfig-config (2.15.0-2.2ubuntu1) ... 110s Setting up python3-pytest (8.3.5-2) ... 110s Setting up python3-pytest-localserver (0.9.0.post0-1) ... 110s Setting up libwebpdemux2:amd64 (1.5.0-0.1) ... 110s Setting up python3-hypothesis (6.130.5-1) ... 111s Setting up libgl1-mesa-dri:amd64 (25.0.7-0ubuntu1) ... 111s Setting up libqt5network5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 111s Setting up libavahi-common3:amd64 (0.8-16ubuntu2) ... 111s Setting up python3-dask (2024.12.1+dfsg-2) ... 112s Setting up libqt5xml5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 112s Setting up libqt5test5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 112s Setting up python3-bs4 (4.13.4-1) ... 112s Setting up python3-sqlalchemy (2.0.38+ds1-0ubuntu2) ... 113s Setting up libinput-bin (1.28.1-1) ... 113s Setting up python3-pytest-forked (1.6.0-3) ... 113s Setting up libegl-mesa0:amd64 (25.0.7-0ubuntu1) ... 113s Setting up libjs-jquery-ui (1.13.2+dfsg-1) ... 113s Setting up libraqm0:amd64 (0.10.2-1) ... 113s Setting up python3-pytest-asyncio (0.25.1-1) ... 113s Setting up libhdf5-310:amd64 (1.14.5+repack-3build1) ... 113s Setting up python3-lxml:amd64 (5.4.0-1build1) ... 113s Setting up libtiff6:amd64 (4.7.0-3ubuntu1) ... 113s Setting up libegl1:amd64 (1.7.0-1build1) ... 113s Setting up libfontconfig1:amd64 (2.15.0-2.2ubuntu1) ... 113s Setting up libsm6:amd64 (2:1.2.6-1) ... 113s Setting up python3-pytestqt (4.4.0-1) ... 113s Setting up libavahi-client3:amd64 (0.8-16ubuntu2) ... 113s Setting up libinput10:amd64 (1.28.1-1) ... 113s Setting up fontconfig (2.15.0-2.2ubuntu1) ... 115s Regenerating fonts cache... done. 115s Setting up libxft2:amd64 (2.3.6-1build1) ... 115s Setting up libglx-mesa0:amd64 (25.0.7-0ubuntu1) ... 115s Setting up python3-pytest-xdist (3.6.1-1) ... 115s Setting up libglx0:amd64 (1.7.0-1build1) ... 115s Setting up python3-tables-lib (3.10.2-2build1) ... 115s Setting up libtk8.6:amd64 (8.6.16-1) ... 115s Setting up python3-tables (3.10.2-2build1) ... 116s Setting up python3.13-tk (3.13.4-1) ... 116s Setting up python3-pil:amd64 (11.1.0-5build1) ... 116s Setting up libgl1:amd64 (1.7.0-1build1) ... 116s Setting up python3-openpyxl (3.1.5+dfsg-2) ... 116s Setting up libxt6t64:amd64 (1:1.2.1-1.2build1) ... 116s Setting up libcups2t64:amd64 (2.4.12-0ubuntu1) ... 116s Setting up tk8.6-blt2.5 (2.5.3+dfsg-8) ... 116s Setting up libxmu6:amd64 (2:1.1.3-3build2) ... 116s Setting up blt (2.5.3+dfsg-8) ... 116s Setting up python3-tk:amd64 (3.13.3-1) ... 116s Setting up libxaw7:amd64 (2:1.0.16-1) ... 116s Setting up libqt5gui5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 116s Setting up python3-pil.imagetk:amd64 (11.1.0-5build1) ... 116s Setting up libqt5widgets5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 116s Setting up x11-xkb-utils (7.7+9) ... 116s Setting up libqt5help5:amd64 (5.15.15-6build1) ... 116s Setting up xserver-common (2:21.1.16-1ubuntu1) ... 116s Setting up libqt5printsupport5t64:amd64 (5.15.15+dfsg-5ubuntu1) ... 116s Setting up libqt5designer5:amd64 (5.15.15-6build1) ... 116s Setting up xvfb (2:21.1.16-1ubuntu1) ... 116s Setting up python3-pyqt5 (5.15.11+dfsg-2) ... 117s Setting up python3-ufolib2 (0.17.1+dfsg1-1) ... 117s Setting up python3-fonttools (4.55.3-2build1) ... 117s Setting up python3-matplotlib (3.10.1+dfsg1-4) ... 118s Processing triggers for libc-bin (2.41-6ubuntu2) ... 118s Processing triggers for man-db (2.13.1-1) ... 119s Processing triggers for udev (257.4-1ubuntu3) ... 120s autopkgtest [20:38:09]: testbed environment configured for cross-architecture building 120s autopkgtest [20:38:09]: test unittests3: [----------------------- 120s ++ dpkg --print-architecture 120s + arch=amd64 120s ++ py3versions -s 120s + pys=python3.13 120s + sourcetestroot=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests 120s + tomlfile=/tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 120s + echo amd64 i386 120s + grep amd64 120s ++ dpkg-vendor --query vendor 120s + '[' Debian = Ubuntu ']' 120s + marker='not slow' 120s + echo amd64 120s + grep -E 'mips|hppa' 120s + PYTEST_WARN_IGNORE= 120s + cd /tmp/autopkgtest.KKmu93/autopkgtest_tmp 120s + TEST_SUCCESS=true 120s + for py in $pys 120s + echo '=== python3.13 ===' 120s === python3.13 === 120s ++ python3.13 -c 'import pandas as pd; print(pd.__path__[0])' 120s + modpath=/usr/lib/python3/dist-packages/pandas 120s + for TEST_SUBSET in $modpath/tests/* 120s + echo /usr/lib/python3/dist-packages/pandas/tests/__init__.py 120s + grep -q -e __pycache__ 120s + PANDAS_CI=1 120s + LC_ALL=C.UTF-8 120s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/__init__.py 121s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 121s 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" 121s 121s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 121s ============================= test session starts ============================== 121s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 121s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 121s rootdir: /usr/lib/python3/dist-packages/pandas 121s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 121s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 121s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 121s collected 0 items 121s 121s =============================== warnings summary =============================== 121s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 121s /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-87me_ts2' 121s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 121s 121s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 121s /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-0mhi082e' 121s session.config.cache.set(STEPWISE_CACHE_DIR, []) 121s 121s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 121s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 121s ============================= 2 warnings in 0.09s ============================== 122s rdjoqkol test state = true 122s + test 5 == 5 122s + echo 'rdjoqkol test state = true' 122s + for TEST_SUBSET in $modpath/tests/* 122s + echo /usr/lib/python3/dist-packages/pandas/tests/__pycache__ 122s + grep -q -e __pycache__ 122s + echo 'rdjoqkol test state = true' 122s + for TEST_SUBSET in $modpath/tests/* 122s rdjoqkol test state = true 122s + echo /usr/lib/python3/dist-packages/pandas/tests/api 122s + grep -q -e __pycache__ 122s + PANDAS_CI=1 122s + LC_ALL=C.UTF-8 122s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/api 122s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 122s 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" 122s 122s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 122s ============================= test session starts ============================== 122s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 122s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 122s rootdir: /usr/lib/python3/dist-packages/pandas 122s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 122s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 122s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 122s collected 14 items 122s 122s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_api.py ............ 122s ../../../usr/lib/python3/dist-packages/pandas/tests/api/test_types.py .. 122s 122s =============================== warnings summary =============================== 122s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 122s /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-0odi3yyz' 122s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 122s 122s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 122s /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-sptxngzm' 122s session.config.cache.set(STEPWISE_CACHE_DIR, []) 122s 122s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 122s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 122s ============================= slowest 30 durations ============================= 122s 122s (30 durations < 0.005s hidden. Use -vv to show these durations.) 122s ======================== 14 passed, 2 warnings in 0.10s ======================== 122s rdjoqkol test state = true 122s + echo 'rdjoqkol test state = true' 122s + for TEST_SUBSET in $modpath/tests/* 122s + echo /usr/lib/python3/dist-packages/pandas/tests/apply 122s + grep -q -e __pycache__ 122s + PANDAS_CI=1 122s + LC_ALL=C.UTF-8 122s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/apply 123s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 123s 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" 123s 123s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 123s ============================= test session starts ============================== 123s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 123s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 123s rootdir: /usr/lib/python3/dist-packages/pandas 123s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 123s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 123s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 123s collected 1243 items 123s 124s ../../../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....... 124s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_apply_relabeling.py ..x.. 125s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_frame_transform.py ...s.s.s................................................ss..ss..ss.....x........x........x........ 125s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_invalid_arg.py ....................................................................................................................................................................................................... 125s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_numba.py sssssssssssssssssss 125s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply.py ................................x.....x....x........................................................................................ 125s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_apply_relabeling.py .. 125s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_series_transform.py ............ 128s ../../../usr/lib/python3/dist-packages/pandas/tests/apply/test_str.py ....................xxxxx...................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...........x...........x...........x...........x........ 128s 128s =============================== warnings summary =============================== 128s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 128s /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-tdrbouho' 128s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 128s 128s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 128s /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-85dx7zf3' 128s session.config.cache.set(STEPWISE_CACHE_DIR, []) 128s 128s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 128s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 128s ============================= slowest 30 durations ============================= 128s 0.04s call tests/apply/test_frame_apply.py::test_apply_differently_indexed 128s 0.03s call tests/apply/test_frame_apply.py::test_agg_transform[axis=1] 128s 0.02s call tests/apply/test_frame_apply.py::test_agg_transform[axis='columns'] 128s 0.02s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=1] 128s 0.02s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='columns'] 128s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops1-names1] 128s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops3-names3] 128s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops3-names3] 128s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops1-names1] 128s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops0-names0] 128s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops0-names0] 128s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis='columns'-ops2-names2] 128s 0.01s call tests/apply/test_frame_transform.py::test_transform_listlike[axis=1-ops2-names2] 128s 0.01s call tests/apply/test_series_apply.py::test_transform[False] 128s 0.01s call tests/apply/test_series_apply.py::test_transform[compat] 128s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis='index'] 128s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_namedtuple 128s 0.01s call tests/apply/test_frame_apply.py::test_agg_reduce[axis=0] 128s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis='columns'-pct_change] 128s 0.01s call tests/apply/test_str.py::test_transform_groupby_kernel_frame[axis=1-pct_change] 128s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis=0] 128s 0.01s call tests/apply/test_frame_apply.py::test_agg_transform[axis='index'] 128s 0.01s teardown tests/apply/test_str.py::test_transform_method_name[rank] 128s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel_partial_functions 128s 0.01s call tests/apply/test_frame_apply.py::test_apply_mutating 128s 0.01s call tests/apply/test_frame_apply_relabeling.py::test_agg_relabel 128s 0.01s call tests/apply/test_series_apply.py::test_with_nested_series[agg] 128s 128s (3 durations < 0.005s hidden. Use -vv to show these durations.) 128s =========== 1153 passed, 73 skipped, 17 xfailed, 2 warnings in 4.80s =========== 128s + echo 'rdjoqkol test state = true' 128s + for TEST_SUBSET in $modpath/tests/* 128s + echo /usr/lib/python3/dist-packages/pandas/tests/arithmetic 128s + grep -q -e __pycache__ 128s rdjoqkol test state = true 128s + PANDAS_CI=1 128s + LC_ALL=C.UTF-8 128s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arithmetic 128s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 128s 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" 128s 128s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 130s ============================= test session starts ============================== 130s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 130s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 130s rootdir: /usr/lib/python3/dist-packages/pandas 130s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 130s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 130s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 130s collected 19330 items 130s 130s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_array_ops.py .. 130s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_categorical.py .. 164s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 165s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_interval.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 169s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 170s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_object.py .......s........................................................................................... 171s ../../../usr/lib/python3/dist-packages/pandas/tests/arithmetic/test_period.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 174s ../../../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......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 174s 174s =============================== warnings summary =============================== 174s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 174s /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-ksdgwmy0' 174s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 174s 174s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 174s /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-31np8vv7' 174s session.config.cache.set(STEPWISE_CACHE_DIR, []) 174s 174s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 174s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 174s ============================= slowest 30 durations ============================= 174s 0.23s call tests/arithmetic/test_datetime64.py::TestDatetimeIndexArithmetic::test_dti_addsub_offset_arraylike[zoneinfo.ZoneInfo(key='US/Pacific')-names3-series-add] 174s 0.13s call tests/arithmetic/test_datetime64.py::TestDatetime64Arithmetic::test_dt64arr_sub_timedeltalike_scalar[tzutc()-timedelta64_1-DataFrame] 174s 0.09s teardown tests/arithmetic/test_timedelta64.py::test_add_timestamp_to_timedelta 174s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-s] 174s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ms] 174s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-us] 174s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_relativedelta_offsets[DataFrame-ns] 174s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-cls_and_kwargs27] 174s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-cls_and_kwargs27] 174s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-False-cls_and_kwargs27] 174s 0.03s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-True-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-False-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-5-False-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-True-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ns-5-False-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-True-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-5-True-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ms-5-False-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-True-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-s-5-False-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-True-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-ns-5-False-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-None-us-5-False-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Series-US/Central-s-5-False-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[Index-US/Central-us-5-False-cls_and_kwargs27] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-0-True-CBMonthBegin] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-us-0-True-CBMonthBegin] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-ms-5-True-CBMonthBegin] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-5-True-CBMonthBegin] 174s 0.02s call tests/arithmetic/test_datetime64.py::TestDatetime64DateOffsetArithmetic::test_dt64arr_add_sub_DateOffsets[DataFrame-US/Central-s-0-True-CBMonthBegin] 174s =============== 19158 passed, 172 skipped, 2 warnings in 45.37s ================ 175s rdjoqkol test state = true 175s + echo 'rdjoqkol test state = true' 175s + for TEST_SUBSET in $modpath/tests/* 175s + echo /usr/lib/python3/dist-packages/pandas/tests/arrays 175s + grep -q -e __pycache__ 175s + PANDAS_CI=1 175s + LC_ALL=C.UTF-8 175s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/arrays 176s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 176s 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" 176s 176s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 179s ============================= test session starts ============================== 179s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 179s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 179s rootdir: /usr/lib/python3/dist-packages/pandas 179s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 179s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 179s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 179s collected 19230 items / 2 skipped 179s 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_arithmetic.py ..................... 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_astype.py ... 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_comparison.py .................................... 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_construction.py ............................. 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_function.py ........... 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_indexing.py ... 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_logical.py ................................................................................... 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_ops.py .. 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_reduction.py .............................. 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/boolean/test_repr.py . 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_algos.py .............. 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_analytics.py ........x..x................................................ 179s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_api.py ................................................................. 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_astype.py ...................... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_constructors.py ....................................................................................................................... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_dtypes.py .................................. 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_indexing.py ............................................................................................................................................... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_map.py ............................. 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_missing.py .......................... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_operators.py ...................................... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_replace.py ...................... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_repr.py ....................... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_sorting.py .... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_subclass.py ... 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_take.py ................ 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/categorical/test_warnings.py s 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_constructors.py ......................ssssssssssssss 180s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_cumulative.py ... 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/datetimes/test_reductions.py ................................................................................................................................................................................................................. 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_arithmetic.py .............................................................. 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_astype.py ......... 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_comparison.py .................................................................................................................. 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_concat.py ... 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_construction.py ............................... 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_contains.py . 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_function.py .................................................... 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_repr.py ........ 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/floating/test_to_numpy.py .............................. 181s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_arithmetic.py ................................................................................................................................................................................................................................................................................................................................................... 182s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_comparison.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 182s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_concat.py .................. 182s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_construction.py ............................................... 182s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_dtypes.py ......................................................................................................................... 182s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_function.py ............................................................................................................................. 182s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_indexing.py .. 182s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_reduction.py ............................................... 182s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/integer/test_repr.py .......................... 182s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_astype.py .. 182s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_formats.py . 183s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval.py .............................................................................. 183s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_interval_pyarrow.py ssssssss 183s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/interval/test_overlaps.py .................................................................................................................... 184s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_arithmetic.py ..............................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss........................................................................................................................................................ss............................................................................................................................................................................................................................................................................................................................................................... 184s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_function.py ..................... 184s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/masked/test_indexing.py ........................................................................................................... 184s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_indexing.py ....................................... 184s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/numpy_/test_numpy.py ....................................................................................... 184s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_astype.py .......... 184s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_constructors.py ..................... 184s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/period/test_reductions.py ... 185s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_accessor.py ............................................. 186s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_arithmetics.py ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 186s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_array.py ........................................................................... 186s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_astype.py ........................ 186s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_combine_concat.py .......... 186s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_constructors.py ................................. 186s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_dtype.py ........................................................ 186s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_indexing.py ................................................................................ 186s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_libsparse.py ..................................................................................... 187s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_reductions.py ....................................................................... 187s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/sparse/test_unary.py ......... 188s ../../../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 188s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/string_/test_string_arrow.py s.ss.ssssssssss.ssssssssssssssssssssssssssssssssss 188s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_array.py ....................................................................................... 202s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimelike.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssss....................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssss.......................................................................................................................................................................................................................................................................................................................................... 205s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_datetimes.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 205s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_ndarray_backed.py ..... 205s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_period.py ................... 205s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/test_timedeltas.py ...................................................................................................................................................... 205s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_constructors.py ........ 205s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_cumulative.py ..... 206s ../../../usr/lib/python3/dist-packages/pandas/tests/arrays/timedeltas/test_reductions.py .......................... 206s 206s =============================== warnings summary =============================== 206s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 206s /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-qivth82d' 206s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 206s 206s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 206s /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-64t4shc_' 206s session.config.cache.set(STEPWISE_CACHE_DIR, []) 206s 206s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 206s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 206s ============================= slowest 30 durations ============================= 206s 0.33s setup tests/arrays/test_timedeltas.py::TestNonNano::test_div_td_scalar[us] 206s 0.22s call tests/arrays/test_datetimelike.py::TestDatetimeArray::test_setitem_object_dtype['UTC+01:15'-QE-list] 206s 0.17s setup tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_bool_array_logical[integer-True] 206s 0.12s teardown tests/arrays/timedeltas/test_reductions.py::TestReductions::test_mean_2d 206s 0.09s call tests/arrays/sparse/test_accessor.py::TestSeriesAccessor::test_from_coo 206s 0.03s call tests/arrays/categorical/test_dtypes.py::TestCategoricalDtypes::test_codes_dtypes 206s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[block] 206s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_mixed_array_comparison[integer] 206s 0.01s call tests/arrays/integer/test_arithmetic.py::test_values_multiplying_large_series_by_NA 206s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[block] 206s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[integer] 206s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_int_array_comparison[block] 206s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[block] 206s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_array_comparison[integer] 206s 0.01s call tests/arrays/sparse/test_arithmetics.py::TestSparseArrayArithmetics::test_float_scalar_comparison[integer] 206s 0.01s call tests/arrays/test_period.py::test_repr_large 206s 206s (14 durations < 0.005s hidden. Use -vv to show these durations.) 206s ========= 18203 passed, 1021 skipped, 8 xfailed, 2 warnings in 29.75s ========== 207s + echo 'rdjoqkol test state = true' 207s + for TEST_SUBSET in $modpath/tests/* 207s + echo /usr/lib/python3/dist-packages/pandas/tests/base 207s + grep -q -e __pycache__ 207s rdjoqkol test state = true 207s + PANDAS_CI=1 207s + LC_ALL=C.UTF-8 207s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/base 208s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 208s 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" 208s 208s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 208s ============================= test session starts ============================== 208s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 208s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 208s rootdir: /usr/lib/python3/dist-packages/pandas 208s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 208s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 208s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 208s collected 1775 items 208s 208s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_constructors.py ....................... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_conversion.py ................................................................................................................................................................................................................................................................................................................................... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_fillna.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss 209s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_misc.py .......................................................................................................................................................................................................................................xx...xxx....................................................................s...... 209s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_transpose.py .............................................................................................................................................................................................................................. 210s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_unique.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss..................................................................................ssssssssssssssssss....ssss..........ssssssss......ss......................................................................ssssssssssss.... 211s ../../../usr/lib/python3/dist-packages/pandas/tests/base/test_value_counts.py ..................................................................................ssssssssssssssssss....ssss........ssssssssss......ss..............................................ss......................ssssssssssss......................... 211s 211s =============================== warnings summary =============================== 211s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 211s /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-iukgwprh' 211s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 211s 211s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 211s /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-cltz5wbc' 211s session.config.cache.set(STEPWISE_CACHE_DIR, []) 211s 211s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 211s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 211s ============================= slowest 30 durations ============================= 211s 0.03s setup tests/base/test_misc.py::test_memory_usage[datetime] 211s 0.03s call tests/base/test_value_counts.py::test_value_counts_null[interval-nan] 211s 0.03s call tests/base/test_value_counts.py::test_value_counts_null[interval-None] 211s 0.02s call tests/base/test_value_counts.py::test_value_counts[interval] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-nan] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-tz-None] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[period-nan] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[period-None] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts[datetime-tz] 211s 0.01s call tests/base/test_unique.py::test_unique_null[period-nan] 211s 0.01s teardown tests/base/test_value_counts.py::test_value_counts_object_inference_deprecated 211s 0.01s call tests/base/test_value_counts.py::test_value_counts[period] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts_bins[index] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-nan] 211s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-nan] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts[timedelta] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts_bins[series] 211s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-tz-None] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[timedelta-None] 211s 0.01s call tests/base/test_unique.py::test_unique[datetime-tz] 211s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-None] 211s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-None] 211s 0.01s call tests/base/test_unique.py::test_unique_null[timedelta-nan] 211s 0.01s call tests/base/test_unique.py::test_unique[period] 211s 0.01s call tests/base/test_unique.py::test_unique_null[datetime-nan] 211s 0.01s call tests/base/test_unique.py::test_unique[timedelta] 211s 0.01s call tests/base/test_unique.py::test_unique_null[period-None] 211s 0.01s call tests/base/test_unique.py::test_unique[datetime] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-nan] 211s 0.01s call tests/base/test_value_counts.py::test_value_counts_null[datetime-None] 211s =========== 1581 passed, 189 skipped, 5 xfailed, 2 warnings in 2.78s =========== 211s + echo 'rdjoqkol test state = true' 211s + for TEST_SUBSET in $modpath/tests/* 211s + echo /usr/lib/python3/dist-packages/pandas/tests/computation 211s + grep -q -e __pycache__ 211s rdjoqkol test state = true 211s + PANDAS_CI=1 211s + LC_ALL=C.UTF-8 211s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/computation 212s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 212s 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" 212s 212s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 212s ============================= test session starts ============================== 212s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 212s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 212s rootdir: /usr/lib/python3/dist-packages/pandas 212s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 212s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 212s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 212s collected 11159 items 212s 212s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_compat.py ..... 250s ../../../usr/lib/python3/dist-packages/pandas/tests/computation/test_eval.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xx..............................xx..............................xx..............................xx.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxxxx..................................................xxxxxxxxxx......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................X.........X....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................xx..xx..... 250s 250s =============================== warnings summary =============================== 250s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 250s /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-v5jbyhfx' 250s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 250s 250s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 250s /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-igkqkspl' 250s session.config.cache.set(STEPWISE_CACHE_DIR, []) 250s 250s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 250s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 250s ============================= slowest 30 durations ============================= 250s 0.16s teardown tests/computation/test_eval.py::TestEval::test_floor_division[DataFrame-SeriesNaN-numexpr-python] 250s 0.08s call tests/computation/test_eval.py::TestEval::test_complex_cmp_ops[SeriesNaN-Series-numexpr-python-and-lt-ge] 250s 0.05s teardown tests/computation/test_eval.py::TestValidate::test_validate_bool_args[5.0] 250s 0.03s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-pandas] 250s 0.03s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[numexpr-python] 250s 0.02s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-python] 250s 0.02s call tests/computation/test_eval.py::TestAlignment::test_performance_warning_for_poor_alignment[python-pandas] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-python] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_lhs_expression_subscript 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-python] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_nested_period_index_subscript_expression 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-&] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-pandas-|] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-|] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[numexpr-python-&] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[numexpr-pandas] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-pandas-|] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-pandas-&] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[python-pandas] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_attr_expression 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-python-&] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_fails_ampersand_pipe[python-python-|] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_check_many_exprs[python-python] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_multi_line_expression 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[numexpr-pandas] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_simple_arith_ops[python-python] 250s 0.01s call tests/computation/test_eval.py::TestOperations::test_basic_period_index_subscript_expression 250s 0.01s call tests/computation/test_eval.py::TestEval::test_chained_cmp_op[float-SeriesNaN-DataFrameNaN-numexpr-pandas-<-<] 250s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-i-i-dt] 250s 0.01s call tests/computation/test_eval.py::TestAlignment::test_medium_complex_frame_alignment[python-pandas-dt-dt-i-i] 250s ========== 11124 passed, 33 xfailed, 2 xpassed, 2 warnings in 38.55s =========== 251s rdjoqkol test state = true 251s + echo 'rdjoqkol test state = true' 251s + for TEST_SUBSET in $modpath/tests/* 251s + echo /usr/lib/python3/dist-packages/pandas/tests/config 251s + grep -q -e __pycache__ 251s + PANDAS_CI=1 251s + LC_ALL=C.UTF-8 251s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/config 252s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 252s 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" 252s 252s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 252s ============================= test session starts ============================== 252s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 252s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 252s rootdir: /usr/lib/python3/dist-packages/pandas 252s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 252s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 252s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 252s collected 50 items 252s 252s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_config.py ..................... 252s ../../../usr/lib/python3/dist-packages/pandas/tests/config/test_localization.py ............................. 252s 252s =============================== warnings summary =============================== 252s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 252s /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-ql799qbg' 252s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 252s 252s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 252s /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-5hdogqpn' 252s session.config.cache.set(STEPWISE_CACHE_DIR, []) 252s 252s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 252s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 252s ============================= slowest 30 durations ============================= 252s 0.01s call tests/config/test_localization.py::test_get_locales_prefix 252s 252s (29 durations < 0.005s hidden. Use -vv to show these durations.) 252s ======================== 50 passed, 2 warnings in 0.46s ======================== 252s + echo 'rdjoqkol test state = true' 252s + for TEST_SUBSET in $modpath/tests/* 252s + echo /usr/lib/python3/dist-packages/pandas/tests/construction 252s + grep -q -e __pycache__ 252s rdjoqkol test state = true 252s + PANDAS_CI=1 252s + LC_ALL=C.UTF-8 252s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/construction 253s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 253s 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" 253s 253s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 253s ============================= test session starts ============================== 253s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 253s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 253s rootdir: /usr/lib/python3/dist-packages/pandas 253s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 253s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 253s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 253s collected 1 item 253s 253s ../../../usr/lib/python3/dist-packages/pandas/tests/construction/test_extract_array.py . 253s 253s =============================== warnings summary =============================== 253s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 253s /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-88jvd28c' 253s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 253s 253s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 253s /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-ynahtmim' 253s session.config.cache.set(STEPWISE_CACHE_DIR, []) 253s 253s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 253s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 253s ============================= slowest 30 durations ============================= 253s 253s (3 durations < 0.005s hidden. Use -vv to show these durations.) 253s ======================== 1 passed, 2 warnings in 0.08s ========================= 253s rdjoqkol test state = true 253s + echo 'rdjoqkol test state = true' 253s + for TEST_SUBSET in $modpath/tests/* 253s + echo /usr/lib/python3/dist-packages/pandas/tests/copy_view 253s + grep -q -e __pycache__ 253s + PANDAS_CI=1 253s + LC_ALL=C.UTF-8 253s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/copy_view 254s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 254s 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" 254s 254s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 255s ============================= test session starts ============================== 255s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 255s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 255s rootdir: /usr/lib/python3/dist-packages/pandas 255s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 255s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 255s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 255s collected 793 items 255s 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_datetimeindex.py ...... 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_index.py ..................... 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_periodindex.py .. 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/index/test_timedeltaindex.py .. 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_array.py ............. 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_astype.py .....ss...s..........s.. 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_chained_assignment_deprecation.py ............... 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_clip.py ...... 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_constructors.py ............................................................................ 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_core_functionalities.py ....... 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_functions.py .................... 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_indexing.py ....................................................................................s.....s........................................................................................................................................ 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_internals.py ..................... 255s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_interp_fillna.py ...................................................... 256s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_methods.py ........................................................................................................................................................................................................................................................ 256s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_replace.py ........................................ 256s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_setitem.py ......... 256s ../../../usr/lib/python3/dist-packages/pandas/tests/copy_view/test_util.py .. 256s 256s =============================== warnings summary =============================== 256s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 256s /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-87ge_zrs' 256s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 256s 256s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 256s /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-17b8b_sy' 256s session.config.cache.set(STEPWISE_CACHE_DIR, []) 256s 256s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 256s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 256s ============================= slowest 30 durations ============================= 256s 0.02s call tests/copy_view/test_internals.py::test_exponential_backoff 256s 256s (29 durations < 0.005s hidden. Use -vv to show these durations.) 256s ================== 787 passed, 6 skipped, 2 warnings in 2.23s ================== 256s rdjoqkol test state = true 256s + echo 'rdjoqkol test state = true' 256s + for TEST_SUBSET in $modpath/tests/* 256s + echo /usr/lib/python3/dist-packages/pandas/tests/dtypes 256s + grep -q -e __pycache__ 256s + PANDAS_CI=1 256s + LC_ALL=C.UTF-8 256s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/dtypes 257s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 257s 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" 257s 257s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 258s ============================= test session starts ============================== 258s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 258s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 258s rootdir: /usr/lib/python3/dist-packages/pandas 258s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 258s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 258s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 258s collected 5628 items 258s 258s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_can_hold_element.py ........... 258s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_from_scalar.py .... 258s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_ndarray.py ....... 258s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_construct_object_arr.py ....................................... 258s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_dict_compat.py . 258s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_downcast.py ................................... 258s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_find_common_type.py .......................................................................................... 258s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_datetimelike.py ... 258s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_infer_dtype.py .................................................................... 258s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_maybe_box_native.py ................ 261s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/cast/test_promote.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 261s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_common.py .............................................................................................................................................................................s...................................................................................................................................................................................................................................................................... 261s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_concat.py .... 262s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_dtypes.py ........................................................................................................................................................................................................................................................................................... 262s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_generic.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 263s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_inference.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss....................................................... 263s ../../../usr/lib/python3/dist-packages/pandas/tests/dtypes/test_missing.py ..........................................................................................................xxxx............................................................................................................................................................................................................. 263s 263s =============================== warnings summary =============================== 263s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 263s /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-2lry1g47' 263s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 263s 263s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 263s /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-9pbaslsp' 263s session.config.cache.set(STEPWISE_CACHE_DIR, []) 263s 263s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 263s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 263s ============================= slowest 30 durations ============================= 263s 0.08s call tests/dtypes/test_common.py::test_is_sparse[True] 263s 0.04s call tests/dtypes/test_inference.py::TestInference::test_maybe_convert_objects_mixed_datetimes 263s 0.03s teardown tests/dtypes/test_missing.py::TestIsValidNAForDtype::test_is_valid_na_for_dtype_categorical 263s 263s (27 durations < 0.005s hidden. Use -vv to show these durations.) 263s ============ 5615 passed, 9 skipped, 4 xfailed, 2 warnings in 6.49s ============ 264s + echo 'rdjoqkol test state = true' 264s + for TEST_SUBSET in $modpath/tests/* 264s + echo /usr/lib/python3/dist-packages/pandas/tests/extension 264s + grep -q -e __pycache__ 264s rdjoqkol test state = true 264s + PANDAS_CI=1 264s + LC_ALL=C.UTF-8 264s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/extension 264s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 264s 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" 264s 264s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 268s ============================= test session starts ============================== 268s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 268s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 268s rootdir: /usr/lib/python3/dist-packages/pandas 268s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 268s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 268s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 268s collected 16808 items / 1 skipped 268s 268s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/array_with_attr/test_array_with_attr.py . 271s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/decimal/test_decimal.py ssssssssssssssssssssssssssssssssssss....................................x.................................................................................................................................................................................................................................................................................................................................xx............................................................s............................xxxxxxxxss..............xxssxxss................................................xxx..................... 282s ../../../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. 282s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/list/test_list.py . 283s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_categorical.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss...................................s.........................................................................................................................ss.................................................................................................xx...........................................................s............x..sxx................x.............xxxxxssssssssssssssssssssssssssssssssssss.. 283s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_common.py ............ 285s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_datetime.py ........................ssss............................................x..............................................................................................ssssssssssssssssssssssss.................................................................s......................................................................................................................................................................................xx..............................................xx...........................................................s............................................ssss......... 285s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_extension.py .............. 286s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_interval.py ssssssssssssssssssssssssssssssssssss....................................x..................................................................................................ssssssssssssssssssssssss.................................................................s...............................................................................................................................ss......................................................xx..............................................xx............................................................s............x. 300s ../../../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 306s ../../../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.. 308s ../../../usr/lib/python3/dist-packages/pandas/tests/extension/test_period.py ..........................................ssss........ssss.....................................................................................x...x..................................................................................................................................................................................................ssssssssssssssssssssssssssssssssssssssssssssssss..................................................................................................................................ss........................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxx.......................................................................................................................s.s............................................................................ssss........ssss................ 318s ../../../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. 322s ../../../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 322s 322s =============================== warnings summary =============================== 322s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 322s /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-mxmvscg1' 322s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 322s 322s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 322s /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-p7ze69m8' 322s session.config.cache.set(STEPWISE_CACHE_DIR, []) 322s 322s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 322s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 322s ============================= slowest 30 durations ============================= 322s 0.14s call tests/extension/test_masked.py::TestMaskedArrays::test_setitem_loc_scalar_mixed[Int16Dtype] 322s 0.10s call tests/extension/json/test_json.py::TestJSONArray::test_unary_ufunc_dunder_equivalence[negative] 322s 0.07s teardown tests/extension/test_string.py::test_searchsorted_with_na_raises[False-False-pyarrow_numpy] 322s 0.04s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index2] 322s 0.04s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_array[__rpow__] 322s 0.04s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index2] 322s 0.04s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[0-series-index3] 322s 0.03s call tests/extension/test_sparse.py::TestSparseArray::test_unstack[nan-series-index3] 322s 0.03s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index2] 322s 0.03s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[frame-index2] 322s 0.03s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index2] 322s 0.03s call tests/extension/test_interval.py::TestIntervalArray::test_unstack[series-index3] 322s 0.03s call tests/extension/test_string.py::TestStringArray::test_unstack[True-python-series-index2] 322s 0.03s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_arith_series_with_array[__pow__] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float32Dtype-series-index2] 322s 0.03s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[float-series-index2] 322s 0.03s call tests/extension/decimal/test_decimal.py::TestDecimalArray::test_unstack[series-index2] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Float64Dtype-series-index2] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int8Dtype-series-index2] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt8Dtype-series-index2] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[BooleanDtype-series-index2] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int32Dtype-series-index2] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt64Dtype-series-index2] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt16Dtype-series-index2] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int64Dtype-series-index2] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[Int16Dtype-series-index2] 322s 0.03s call tests/extension/test_numpy.py::TestNumpyExtensionArray::test_unstack[object-series-index2] 322s 0.03s call tests/extension/test_masked.py::TestMaskedArrays::test_unstack[UInt32Dtype-series-index2] 322s 0.03s call tests/extension/test_string.py::TestStringArray::test_unstack[False-python-series-index3] 322s 0.03s call tests/extension/test_string.py::TestStringArray::test_unstack[True-python-series-index3] 322s ======== 12106 passed, 4371 skipped, 332 xfailed, 2 warnings in 57.78s ========= 323s + echo 'rdjoqkol test state = true' 323s + for TEST_SUBSET in $modpath/tests/* 323s + echo /usr/lib/python3/dist-packages/pandas/tests/frame 323s rdjoqkol test state = true 323s + grep -q -e __pycache__ 323s + PANDAS_CI=1 323s + LC_ALL=C.UTF-8 323s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/frame 324s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 324s 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" 324s 324s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 329s ============================= test session starts ============================== 329s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 329s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 329s rootdir: /usr/lib/python3/dist-packages/pandas 329s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 329s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 329s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 329s collected 11172 items / 433 deselected / 1 skipped / 10739 selected 329s 329s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_dict.py .............. 329s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/constructors/test_from_records.py ........................... 329s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_coercion.py .......x.x. 329s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_delitem.py .... 329s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get.py .... 329s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_get_value.py .. 329s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_getitem.py ........................................ 331s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_indexing.py ...................................................................................................................................................................................................................................sss................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 331s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_insert.py ....... 331s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_mask.py ........... 331s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_set_value.py ... 331s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_setitem.py ........................................................................................................s..........................................................................................xxx...........................x..x..x..x........ 331s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_take.py .... 333s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_where.py ............................................................................................................................................. 334s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/indexing/test_xs.py .............................. 334s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_add_prefix_suffix.py ... 334s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_align.py ........................................................................................................................................................................................................................................................................................................................................................................................................................ 334s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asfreq.py ........................................ 335s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_asof.py ........... 335s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_assign.py ..... 335s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_astype.py .......................................................................................................................s....s........................................................................................................ss.....ssssssssss 335s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_at_time.py ...................... 335s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_between_time.py .............................. 335s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_clip.py ..................... 335s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine.py ..... 336s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_combine_first.py ..................................s............................... 336s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_compare.py ......................... 336s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_convert_dtypes.py ..ssss..ssss.sss.. 336s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_copy.py ..... 336s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_count.py .. 336s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_cov_corr.py .............................................................s............ 336s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_describe.py ...............................................s 336s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_diff.py .............................................. 336s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dot.py ................sss 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop.py ......................................................................... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_drop_duplicates.py ..................................... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_droplevel.py .. 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dropna.py ................... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_dtypes.py ........ 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_duplicated.py .......xxx........... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_equals.py ... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_explode.py ..................... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_fillna.py ................................................................. 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_filter.py ........... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_and_last.py ............. 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_first_valid_index.py ............... 337s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_get_numeric_data.py .... 338s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_head_tail.py .................................................................. 338s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_infer_objects.py . 339s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_info.py ..........................x......s...... 339s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_interpolate.py ...................................................................ssssssssss 339s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_is_homogeneous_dtype.py ....... 339s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isetitem.py ... 339s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_isin.py ................. 339s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_iterrows.py . 339s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_join.py ...........s................... 339s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_map.py ......................... 339s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_matmul.py .. 340s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_nlargest.py .........................................................................................................................................................................................................................................................x.....x.....x.....x.......x..... 340s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pct_change.py ............................. 340s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pipe.py ...... 340s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_pop.py ... 342s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_quantile.py ........................................................................xx..........xx..........xx..........xx.................. 344s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rank.py .........................................................................................................................ss 344s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex.py ................................................................................................................................................. 344s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reindex_like.py ..... 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename.py ......................... 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_rename_axis.py ......... 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reorder_levels.py ... 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_replace.py ...................ss.................ssss....ssss................................................................................................................................................................. 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_reset_index.py ................................................................................................................................ 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_round.py ......... 345s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sample.py .......................................................... 346s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_select_dtypes.py ..................................s...... 346s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_axis.py .............. 347s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_set_index.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_shift.py ...................................................................................x.x.x.x.x.xxxx........ 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_size.py ..... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_index.py ................................................................. 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_sort_values.py ...................................................X...............................xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX..... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swapaxes.py .... 350s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_swaplevel.py . 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_csv.py ............................................................................. 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict.py ...................................................................................................... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_dict_of_blocks.py ... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_numpy.py .... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_period.py ...................................................................... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_records.py ................................... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_to_timestamp.py ...................................................................... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_transpose.py ................... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_truncate.py ........................................................................................ 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_convert.py ........... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_tz_localize.py ......... 352s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_update.py .............. 353s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_value_counts.py ................................. 353s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/methods/test_values.py ............... 353s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_alter_axes.py .. 353s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_api.py ......................ss.......... 355s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..........x................................................................................................................................ 355s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_block_internals.py ................... 357s ../../../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................................ 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_cumulative.py ....... 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_iteration.py .................... 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_logical_ops.py ................. 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_nonunique_indexes.py ................ 357s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_npfuncs.py .... 359s ../../../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. 362s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_reductions.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s....................................................................................................x.............x............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 362s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_repr.py ..........................................ssss................ 367s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_stack_unstack.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 367s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_subclass.py .................................................... 368s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 368s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_unary.py .................. 368s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_validate.py ............................ 368s 368s =============================== warnings summary =============================== 368s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 368s /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-786zn4h3' 368s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 368s 368s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 368s /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-69thysiq' 368s session.config.cache.set(STEPWISE_CACHE_DIR, []) 368s 368s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 368s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 368s ============================= slowest 30 durations ============================= 368s 1.74s call tests/frame/indexing/test_where.py::test_where_inplace_casting 368s 1.67s call tests/frame/methods/test_rank.py::TestRank::test_pct_max_many_rows 368s 0.41s call tests/frame/test_api.py::TestDataFrameMisc::test_inspect_getmembers 368s 0.30s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorr::test_corr_scipy_method[kendall] 368s 0.27s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[10000] 368s 0.26s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[50000] 368s 0.26s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_chunking[100000] 368s 0.25s call tests/frame/test_reductions.py::TestDataFrameAnalytics::test_idxmax_empty[int64-False-1] 368s 0.24s 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] 368s 0.20s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_with_dst_transitions_with_pickle 368s 0.18s call tests/frame/test_api.py::TestDataFrameMisc::test_attrs 368s 0.18s call tests/frame/methods/test_info.py::test_info_verbose_check_header_separator_body 368s 0.12s call tests/frame/methods/test_cov_corr.py::TestDataFrameCorrWith::test_corrwith[Float64] 368s 0.09s call tests/frame/methods/test_to_csv.py::TestDataFrameToCSV::test_to_csv_dups_cols 368s 0.09s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[False] 368s 0.09s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[False] 368s 0.08s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[index] 368s 0.08s call tests/frame/methods/test_at_time.py::TestAtTime::test_at_time_axis[0] 368s 0.07s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack[True] 368s 0.07s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_bytes_61_lines 368s 0.06s call tests/frame/test_repr.py::TestDataFrameRepr::test_repr_to_string 368s 0.06s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_order_with_unsorted_levels_multi_row[True] 368s 0.06s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[False] 368s 0.05s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[index-0] 368s 0.05s call tests/frame/test_stack_unstack.py::TestStackUnstackMultiLevel::test_stack_unstack_multiple[True] 368s 0.05s teardown tests/frame/test_validate.py::TestDataFrameValidate::test_validate_bool_args[5.0-sort_values] 368s 0.05s call tests/frame/methods/test_interpolate.py::TestDataFrameInterpolate::test_interp_string_axis[columns-1] 368s 0.04s call tests/frame/test_iteration.py::TestIteration::test_itertuples_py2_3_field_limit_namedtuple[True-1024] 368s 0.04s call tests/frame/test_iteration.py::TestIteration::test_itertuples_py2_3_field_limit_namedtuple[False-1024] 368s 0.04s call tests/frame/test_stack_unstack.py::TestDataFrameReshape::test_stack_int_level_names[False] 368s = 10438 passed, 206 skipped, 433 deselected, 64 xfailed, 32 xpassed, 2 warnings in 44.29s = 370s rdjoqkol test state = true 370s + echo 'rdjoqkol test state = true' 370s + for TEST_SUBSET in $modpath/tests/* 370s + echo /usr/lib/python3/dist-packages/pandas/tests/generic 370s + grep -q -e __pycache__ 370s + PANDAS_CI=1 370s + LC_ALL=C.UTF-8 370s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/generic 370s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 370s 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" 370s 370s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 371s ============================= test session starts ============================== 371s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 371s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 371s rootdir: /usr/lib/python3/dist-packages/pandas 371s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 371s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 371s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 371s collected 1249 items 371s 371s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_duplicate_labels.py ..........xx...........x.......xx.xxx................x................ 374s ../../../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. 374s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_frame.py ............... 374s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_generic.py ................................................................................. 374s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_label_or_level_utils.py ....................................................................... 374s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_series.py ................... 375s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py expected 375s bar a b c d e f g h 375s foo 375s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='datetime64[ns]', name='foo', freq='D') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) datetime64[ns] 32B 2020-01-01 2020-01-02 ... 2020-01-04 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s DatetimeIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='datetime64[ns]', name='foo', freq='D') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c ... f g h 375s foo ... 375s 2020-01-01 00:00:00-08:00 a 1 3 ... a 2013-01-01 2013-01-01 00:00:00-05:00 375s 2020-01-02 00:00:00-08:00 b 2 4 ... b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2020-01-03 00:00:00-08:00 c 3 5 ... c 2013-01-03 2013-01-03 00:00:00-05:00 375s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 375s 375s [4 rows x 8 columns] 375s DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 375s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 375s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B 1577865600000000000 ... 1578124800000000000 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c ... f g h 375s foo ... 375s 2020-01-01 00:00:00-08:00 a 1 3 ... NaN 2013-01-01 2013-01-01 00:00:00-05:00 375s 2020-01-02 00:00:00-08:00 b 2 4 ... NaN 2013-01-02 2013-01-02 00:00:00-05:00 375s 2020-01-03 00:00:00-08:00 c 3 5 ... NaN 2013-01-03 2013-01-03 00:00:00-05:00 375s 2020-01-04 00:00:00-08:00 d 4 6 ... NaN 2013-01-04 2013-01-04 00:00:00-05:00 375s 375s [4 rows x 8 columns] 375s Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 375s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 375s dtype='object', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s xexpected 375s bar a b c d e f g h 375s foo 375s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s PeriodIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='period[D]', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B 2020-01-01 2020-01-02 2020-01-03 2020-01-04 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 2020-01-01 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 2020-01-02 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2020-01-03 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 2020-01-04 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s PeriodIndex(['2020-01-01', '2020-01-02', '2020-01-03', '2020-01-04'], dtype='period[D]', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 1 days a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 2 days b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 3 days c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 4 days d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', name='foo', freq='D') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) timedelta64[ns] 32B 1 days 2 days 3 days 4 days 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 1 days a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 2 days b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 3 days c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 4 days d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', name='foo', freq='D') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s RangeIndex(start=0, stop=4, step=1, name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) int64 32B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s RangeIndex(start=0, stop=4, step=1, name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='int8', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 208B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) int8 4B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='int8', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='int16', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 212B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) int16 8B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='int16', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='int32', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 220B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) int32 16B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='int32', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='int64', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) int64 32B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='int64', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='uint8', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 208B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) uint8 4B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='uint8', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='uint16', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 212B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) uint16 8B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='uint16', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='uint32', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 220B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) uint32 16B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='uint32', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='uint64', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) uint64 32B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='uint64', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0.0, 1.0, 2.0, 3.0], dtype='float32', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 220B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) float32 16B 0.0 1.0 2.0 3.0 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0.0, 1.0, 2.0, 3.0], dtype='float32', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0.0, 1.0, 2.0, 3.0], dtype='float64', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) float64 32B 0.0 1.0 2.0 3.0 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0.0, 1.0, 2.0, 3.0], dtype='float64', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([True, False, True, False], dtype='object', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B True False True False 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s True a 1 3 4.0 True c 2013-01-01 2013-01-01 00:00:00-05:00 375s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s False b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 375s True c 3 5 6.0 True a 2013-01-03 2013-01-03 00:00:00-05:00 375s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s False d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 375s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([True, True, False, False, True, True, False, False], dtype='object', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s xexpected 375s bar a b c d e f g h 375s foo 375s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([True, False, True, False], dtype='bool', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 208B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) bool 4B True False True False 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s True a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s True a 1 3 4.0 True c 2013-01-01 2013-01-01 00:00:00-05:00 375s False b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s False b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 375s True c 3 5 6.0 True a 2013-01-03 2013-01-03 00:00:00-05:00 375s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s False d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 375s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([True, True, False, False, True, True, False, False], dtype='bool', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s xexpected 375s bar a b c d e f g h 375s foo 375s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex64', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) complex64 32B 0j (1+1j) (2+2j) (3+3j) 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex64', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex128', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 268B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) complex128 64B 0j (1+1j) (2+2j) (3+3j) 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0.0+0.0j a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1.0+1.0j b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2.0+2.0j c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3.0+3.0j d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0j, (1+1j), (2+2j), (3+3j)], dtype='complex128', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xexpected 375s bar a b c d e f g h 375s foo 375s a a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s b b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s c c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B 'a' 'b' 'c' 'd' 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s a a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s b b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s c c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s xexpected 375s bar a b c d e f g h 375s foo 375s (0.0, 1.0] a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s (1.0, 2.0] b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s (2.0, 3.0] c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s (3.0, 4.0] d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]], dtype='interval[float64, right]', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B (0.0, 1.0] (1.0, 2.0] (2.0, 3.0] (3.0, 4.0] 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s (0.0, 1.0] a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s (1.0, 2.0] b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s (2.0, 3.0] c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s (3.0, 4.0] d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s IntervalIndex([(0.0, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]], dtype='interval[float64, right]', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s Xsexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 1 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 0, 1, 1], dtype='int64', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) int64 32B 0 0 1 1 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 0 a 1 3 4.0 True b 2013-01-01 2013-01-01 00:00:00-05:00 375s 0 b 2 4 5.0 False a 2013-01-02 2013-01-02 00:00:00-05:00 375s 0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 1 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 1 c 3 5 6.0 True d 2013-01-03 2013-01-03 00:00:00-05:00 375s 1 d 4 6 7.0 False c 2013-01-04 2013-01-04 00:00:00-05:00 375s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 0, 0, 0, 1, 1, 1, 1], dtype='int64', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='Int64', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='object', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s xexpected 375s bar a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='UInt16', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B 0 1 2 3 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0, 1, 2, 3], dtype='object', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s xexpected 375s bar a b c d e f g h 375s foo 375s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B 0.0 1.0 2.0 3.0 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s 0.0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s 1.0 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s 2.0 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s xexpected 375s bar a b c d e f g h 375s foo 375s False a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s True b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([False, True, True, True], dtype='boolean', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B False True True True 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s False a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s True b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s True b 2 4 5.0 False c 2013-01-02 2013-01-02 00:00:00-05:00 375s True b 2 4 5.0 False d 2013-01-02 2013-01-02 00:00:00-05:00 375s True c 3 5 6.0 True b 2013-01-03 2013-01-03 00:00:00-05:00 375s True c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s True c 3 5 6.0 True d 2013-01-03 2013-01-03 00:00:00-05:00 375s True d 4 6 7.0 False b 2013-01-04 2013-01-04 00:00:00-05:00 375s True d 4 6 7.0 False c 2013-01-04 2013-01-04 00:00:00-05:00 375s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index([False, True, True, True, True, True, True, True, True, True], dtype='object', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s xexpected 375s bar a b c d e f g h 375s foo 375s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 375s bar 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s actual 375s Size: 236B 375s Dimensions: (foo: 4) 375s Coordinates: 375s * foo (foo) object 32B 'pandas_0' 'pandas_1' 'pandas_2' 'pandas_3' 375s Data variables: 375s a (foo) object 32B 'a' 'b' 'c' 'd' 375s b (foo) int64 32B 1 2 3 4 375s c (foo) uint8 4B 3 4 5 6 375s d (foo) float64 32B 4.0 5.0 6.0 7.0 375s e (foo) bool 4B True False True False 375s f (foo) category 36B PandasExtensionArray(array=['a', 'b', 'c', 'd... 375s g (foo) datetime64[ns] 32B 2013-01-01 2013-01-02 ... 2013-01-04 375s h (foo) object 32B 2013-01-01T00:00:00-05:00 ... 2013-01-04T00:00:... 375s a b c d e f g h 375s foo 375s pandas_0 a 1 3 4.0 True a 2013-01-01 2013-01-01 00:00:00-05:00 375s pandas_1 b 2 4 5.0 False b 2013-01-02 2013-01-02 00:00:00-05:00 375s pandas_2 c 3 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 375s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 375s Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 375s a object 375s b int64 375s c uint8 375s d float64 375s e bool 375s f category 375s g datetime64[ns] 375s h datetime64[ns, US/Eastern] 375s dtype: object 375s x................................. 375s 375s =============================== warnings summary =============================== 375s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 375s /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-jl3w73t6' 375s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 375s 375s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 375s /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-vuo3ooqb' 375s session.config.cache.set(STEPWISE_CACHE_DIR, []) 375s 375s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 375s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 375s ============================= slowest 30 durations ============================= 375s 0.27s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int32] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[interval] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[complex128] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[complex64] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime] 375s 0.02s call tests/generic/test_generic.py::TestGeneric::test_truncate_out_of_bounds[DataFrame] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[float32] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[float64] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[period] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[timedelta] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint8] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int8] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint16] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int64] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint64] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[uint32] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[int16] 375s 0.02s call tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[range] 375s 0.01s call tests/generic/test_generic.py::TestGeneric::test_truncate_out_of_bounds[Series] 375s ==== 978 passed, 105 skipped, 148 xfailed, 18 xpassed, 2 warnings in 5.18s ===== 376s rdjoqkol test state = true 376s + echo 'rdjoqkol test state = true' 376s + for TEST_SUBSET in $modpath/tests/* 376s + echo /usr/lib/python3/dist-packages/pandas/tests/groupby 376s + grep -q -e __pycache__ 376s + PANDAS_CI=1 376s + LC_ALL=C.UTF-8 376s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/groupby 376s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 376s 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" 376s 376s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 379s ============================= test session starts ============================== 379s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 379s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 379s rootdir: /usr/lib/python3/dist-packages/pandas 379s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 379s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 379s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 379s collected 29434 items / 1832 deselected / 1 skipped / 27602 selected 379s 381s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_aggregate.py ...............................................................................................................................................................................................................................................................................................................................................x..x.......................................................................x....... 381s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_cython.py ........................................................................................................................................................................ 381s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 381s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_other.py ........................................ 381s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_corrwith.py . 381s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_describe.py ......................... 381s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_groupby_shift_diff.py ............................................... 381s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_is_monotonic.py ...... 382s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_nlargest_nsmallest.py ........................................... 382s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_nth.py .................................................................................................................................................................................................................................... 383s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_quantile.py ..................................................................................................x....x.......................................................................................................................................................................................................................... 385s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_rank.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 386s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_sample.py .............. 387s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_size.py .......x....x....x....x....x....x....x....x...............ss 387s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/methods/test_skew.py . 389s ../../../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...................................... 389s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_all_methods.py ......................................xx..............................................................................................ss..........ss..............ss...... 389s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_api.py ......s..s..............................s..s.......................... 389s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_apply.py .................................................................................................................................... 389s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_apply_mutate.py ..... 389s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_bin_groupby.py ...... 400s ../../../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................................ 400s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_counting.py .................................ssss 400s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_cumulative.py ..................................................... 400s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_filters.py ............................ 407s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby.py ......................................s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s...................s................................................................................................................... 422s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby_dropna.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................xxxxxxxx.................................................. 422s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_groupby_subclass.py .....s................................................................. 423s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_grouping.py ....................................................................................... 423s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_index_as_string.py .................. 423s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_indexing.py ............................................................................................................................................................................ 423s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_libgroupby.py ........................... 423s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_missing.py ......................... 424s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numeric_only.py ..................xxx......ssssss..............................xxx.................................................................................................................................................................................................................................................................................................................................................................................. 424s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_pipe.py .. 444s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_raises.py ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 446s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_reductions.py ...............................................................................................................................................................................................................................................................................................................ss........................................................................................................................................................ 446s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 446s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 456s ../../../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............................................................................................................................................................................................................ 456s 456s =============================== warnings summary =============================== 456s tests/groupby/test_categorical.py::test_basic 456s /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) 456s return reduction(axis=axis, out=out, **passkwargs) 456s 456s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 456s /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-5btsmfic' 456s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 456s 456s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 456s /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-kha_uwo_' 456s session.config.cache.set(STEPWISE_CACHE_DIR, []) 456s 456s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 456s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 456s ============================= slowest 30 durations ============================= 456s 0.44s call tests/groupby/test_raises.py::test_groupby_raises_category_on_category[by2-True-cumsum-False-agg] 456s 0.33s call tests/groupby/test_reductions.py::test_ops_general[sem-scipy_sem] 456s 0.22s call tests/groupby/test_groupby.py::test_empty_groupby[False-skew-agg-float-keys1-C] 456s 0.13s teardown tests/groupby/transform/test_transform.py::test_idxmin_idxmax_transform_args[False-False-idxmin] 456s 0.06s call tests/groupby/test_categorical.py::test_basic 456s 0.05s call tests/groupby/test_counting.py::test_count 456s 0.04s call tests/groupby/test_counting.py::TestCounting::test_ngroup_cumcount_pair 456s 0.04s call tests/groupby/test_timegrouper.py::TestGroupBy::test_timegrouper_with_reg_groups 456s 0.04s call tests/groupby/test_groupby_subclass.py::test_groupby_preserves_subclass[corrwith-obj0] 456s 0.03s call tests/groupby/test_categorical.py::test_datetime 456s 0.03s call tests/groupby/test_apply.py::test_apply_concat_preserve_names 456s 0.03s call tests/groupby/methods/test_describe.py::test_frame_describe_multikey 456s 0.03s call tests/groupby/test_groupby.py::test_groupby_multiindex_not_lexsorted 456s 0.02s call tests/groupby/transform/test_transform.py::test_as_index_no_change[corrwith-keys1] 456s 0.02s call tests/groupby/transform/test_transform.py::test_transform_fast 456s 0.02s call tests/groupby/test_apply.py::test_apply_corner_cases 456s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-True-multi] 456s 0.02s call tests/groupby/test_categorical.py::test_observed[False] 456s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-False-multi] 456s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-True-multi] 456s 0.02s call tests/groupby/test_libgroupby.py::TestGroupVarFloat64::test_group_var_large_inputs 456s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-True-False-multi] 456s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-False-True-multi] 456s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-True-True-multi] 456s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-False-False-multi] 456s 0.02s call tests/groupby/test_groupby.py::test_groupby_as_index_agg 456s 0.02s call tests/groupby/test_categorical.py::test_describe_categorical_columns 456s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-False-False-range] 456s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-False-False-True-single] 456s 0.02s call tests/groupby/test_groupby_dropna.py::test_categorical_reducers[corrwith-True-True-False-multi] 456s = 26564 passed, 910 skipped, 1832 deselected, 90 xfailed, 39 xpassed, 3 warnings in 79.99s (0:01:19) = 459s rdjoqkol test state = true 459s + echo 'rdjoqkol test state = true' 459s + for TEST_SUBSET in $modpath/tests/* 459s + echo /usr/lib/python3/dist-packages/pandas/tests/indexes 459s + grep -q -e __pycache__ 459s + PANDAS_CI=1 459s + LC_ALL=C.UTF-8 459s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/indexes 459s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 459s 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" 459s 459s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 465s ============================= test session starts ============================== 465s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 465s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 465s rootdir: /usr/lib/python3/dist-packages/pandas 465s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 465s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 465s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 465s collected 17010 items / 4 deselected / 17006 selected 465s 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_constructors.py .......s.. 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_formats.py .............. 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_indexing.py ............ 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_pickle.py . 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_reshape.py ..............s.... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_setops.py ............................................................ 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/base_class/test_where.py . 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_append.py ....... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_astype.py ........... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_category.py ......................................... 465s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_constructors.py ..... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_equals.py ......ss 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_fillna.py ... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_formats.py .. 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_indexing.py ................................. 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_map.py ..................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_reindex.py ....... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/categorical/test_setops.py .. 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_drop_duplicates.py ................................................................................................................ 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_equals.py ..................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_indexing.py ................ 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_is_monotonic.py . 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_nat.py ...................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_sort_values.py ................................................................................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimelike_/test_value_counts.py ............................................ 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_asof.py .. 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_astype.py ................................. 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_delete.py ....................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_factorize.py .................................................................................... 466s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_fillna.py .. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_insert.py ............................................................................................................................................................................................. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_isocalendar.py .. 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_map.py ..... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_normalize.py ......... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_repeat.py .................................................................................................................................................................................................................................................................................................................................................... 467s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_resolution.py .................................................................................................................................................................................... 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_round.py ...................................................................................................................................................................................................................... 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_shift.py ........................................................................................................................................ 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_snap.py ........................ 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_frame.py .. 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_julian_date.py ..... 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_period.py ........................................... 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_pydatetime.py .. 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_to_series.py . 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_tz_convert.py .................................... 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_tz_localize.py ............................................................................................................................................................ 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/methods/test_unique.py ........................ 468s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_arithmetic.py .....................x 469s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_constructors.py ..................................................................................................................................................................................................................x...x.................................... 470s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_date_range.py .................................................................................................................................................................................................................................................................................................................................................. 470s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_datetime.py .................. 470s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_formats.py ........................................ 470s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_freq_attr.py .......................... 471s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................... 471s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_iter.py ............ 471s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_join.py ...................... 471s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_npfuncs.py . 471s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_ops.py ................ 471s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_partial_slicing.py .................................. 471s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_pickle.py ...... 471s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_reindex.py .. 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_scalar_compat.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_setops.py ................................................................................................................................ 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/datetimes/test_timezones.py ........................................ 476s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_astype.py ....................................x........................................................................................................................... 477s ../../../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 477s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_equals.py .... 477s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_formats.py ........... 477s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_indexing.py ............................................................................................................................................................................................................................................................................................ 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval.py .......x....x....x....x.................................................................................................................................................................................................................................. 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval_range.py ........................................................................................................................................................ 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_interval_tree.py .................................................................................................................................................................................................................... 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_join.py ... 478s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_pickle.py ... 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/interval/test_setops.py ................................................................................. 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_analytics.py ...................................... 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_astype.py ... 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_compat.py ...... 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_constructors.py ..................................................................................s................. 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_conversion.py ...... 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_copy.py .......... 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_drop.py ............. 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_duplicates.py .................................................. 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_equivalence.py .............. 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_formats.py .............. 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_get_level_values.py ....... 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_get_set.py ................... 479s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_indexing.py ........................................................................................................................................... 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_integrity.py ................ 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_isin.py .............. 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_join.py ....................................................... 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_lexsort.py .. 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_missing.py ...x.. 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_monotonic.py ........... 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_names.py ............................... 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_partial_indexing.py ..... 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_pickle.py . 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_reindex.py ............ 480s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_reshape.py ........... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_setops.py ............................................................................................................................................................................................................sss................................................................... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_sorting.py .......................... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/multi/test_take.py ... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_astype.py ................... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_indexing.py ..............................................................................................................................................ss.......................................... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_join.py ........... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_numeric.py ................................................................................................ 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/numeric/test_setops.py .................... 481s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/object/test_astype.py .. 482s ../../../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. 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_asfreq.py ............... 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_astype.py ............. 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_factorize.py .. 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_fillna.py . 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_insert.py ... 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_is_full.py . 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_repeat.py ...... 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_shift.py ...... 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/methods/test_to_timestamp.py ........ 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_constructors.py .................................................................................................. 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_formats.py ................... 482s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_freq_attr.py . 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_indexing.py ......................................................................... 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_join.py ........... 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_monotonic.py .. 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_partial_slicing.py .............. 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_period.py .................................................................................................................................... 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_period_range.py ........................... 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_pickle.py .... 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_resolution.py ......... 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_scalar_compat.py ... 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_searchsorted.py ........ 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_setops.py .............. 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/period/test_tools.py ............ 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_constructors.py ............................. 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_indexing.py ............... 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_join.py .......... 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_range.py ................................................................................. 483s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/ranges/test_setops.py ................................................................... 484s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_any_index.py ......................................................................................................................s......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 485s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_base.py .........................................................................................................................................................................x.............................................................................ssss....ss..........ss......ss.................................................................................................................................ssss...........................................................................................................................................................................................................................................s.......................................................................................................s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s 486s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_common.py ...........................................................................................................................................................................................................xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.........................................................................................................................sssssssss...s....ss..........................xs.....................sss................................................sss....................................................................................s................s...............................................................................................................................................................................................................................................................................XX........................................... 486s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_datetimelike.py ........................................ 486s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_engines.py ......................................... 486s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_frozen.py .......... 487s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_index_new.py ............................................xxxxssss................................................................................................................ 487s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_indexing.py ......................................................ss...............................s.................................................................................................................................................................................................................................................................................................s........................ 488s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_numpy_compat.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss..................... 489s ../../../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... 493s ../../../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 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/test_subclass.py . 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_astype.py ............... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_factorize.py .. 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_fillna.py . 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_insert.py ............... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_repeat.py . 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/methods/test_shift.py ...... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_arithmetic.py ... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_constructors.py ..................... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_delete.py ... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_formats.py ..... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_freq_attr.py ........... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_indexing.py .................................... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_join.py ....... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_ops.py .......... 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_pickle.py . 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_scalar_compat.py ........ 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_searchsorted.py ........ 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_setops.py ................................ 493s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_timedelta.py ... 494s ../../../usr/lib/python3/dist-packages/pandas/tests/indexes/timedeltas/test_timedelta_range.py ............................ 494s 494s =============================== warnings summary =============================== 494s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 494s /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-10vt7xsb' 494s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 494s 494s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 494s /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-nrke2p1o' 494s session.config.cache.set(STEPWISE_CACHE_DIR, []) 494s 494s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 494s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 494s ============================= slowest 30 durations ============================= 494s 0.29s call tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-tanh] 494s 0.26s call tests/indexes/period/test_indexing.py::TestGetItem::test_getitem_seconds 494s 0.16s call tests/indexes/datetimes/test_date_range.py::TestGenRangeGeneration::test_generate[B-offset0] 494s 0.12s call tests/indexes/ranges/test_setops.py::test_range_difference 494s 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] 494s 0.08s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[us] 494s 0.08s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[s] 494s 0.08s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[ms] 494s 0.08s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[ns] 494s 0.08s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_begin[ns] 494s 0.08s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[s] 494s 0.08s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[ms] 494s 0.08s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonTickFreq::test_date_range_custom_business_month_end[us] 494s 0.07s call tests/indexes/multi/test_indexing.py::test_pyint_engine 494s 0.04s call tests/indexes/datetimes/methods/test_tz_localize.py::TestTZLocalize::test_dti_tz_localize_roundtrip[tzlocal()] 494s 0.04s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[both-1] 494s 0.04s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[neither-1] 494s 0.04s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[left-1] 494s 0.04s call tests/indexes/period/test_partial_slicing.py::TestPeriodIndex::test_range_slice_seconds[period_range] 494s 0.03s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[right-1] 494s 0.03s call tests/indexes/multi/test_sorting.py::test_remove_unused_levels_large[datetime64[D]-str] 494s 0.03s call tests/indexes/datetimes/methods/test_tz_localize.py::TestTZLocalize::test_dti_tz_localize_roundtrip[zoneinfo.ZoneInfo(key='US/Pacific')] 494s 0.03s call tests/indexes/datetimes/test_timezones.py::TestDatetimeIndexTimezones::test_with_tz[tz0] 494s 0.03s call tests/indexes/datetimes/test_timezones.py::TestDatetimeIndexTimezones::test_with_tz[tz1] 494s 0.03s call tests/indexes/multi/test_integrity.py::test_consistency 494s 0.02s call tests/indexes/datetimes/test_constructors.py::TestDatetimeIndex::test_constructor_datetime64_tzformat[W-SUN] 494s 0.02s call tests/indexes/datetimes/test_date_range.py::TestDateRangeNonNano::test_date_range_freq_matches_reso 494s 0.02s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[right-10] 494s 0.02s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[both-10] 494s 0.02s call tests/indexes/interval/test_interval_tree.py::TestIntervalTree::test_get_indexer_closed[left-10] 494s = 16700 passed, 254 skipped, 4 deselected, 46 xfailed, 6 xpassed, 2 warnings in 34.46s = 495s rdjoqkol test state = true 495s + echo 'rdjoqkol test state = true' 495s + for TEST_SUBSET in $modpath/tests/* 495s + echo /usr/lib/python3/dist-packages/pandas/tests/indexing 495s + grep -q -e __pycache__ 495s + PANDAS_CI=1 495s + LC_ALL=C.UTF-8 495s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/indexing 496s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 496s 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" 496s 496s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 497s ============================= test session starts ============================== 497s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 497s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 497s rootdir: /usr/lib/python3/dist-packages/pandas 497s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 497s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 497s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 497s collected 4389 items 497s 497s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/interval/test_interval.py .............................. 497s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/interval/test_interval_new.py ..................... 497s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_chaining_and_caching.py .. 497s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_datetime.py .. 498s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_getitem.py ............................................................................. 498s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_iloc.py ................ 498s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_indexing_slow.py .......... 499s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_loc.py ................................................................................................................................. 499s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_multiindex.py ................ 499s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_partial.py ............. 499s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_setitem.py ........................... 499s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_slice.py ............................. 499s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/multiindex/test_sorted.py ......... 499s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_at.py ......................................... 500s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_categorical.py .................s................................................................................................ 500s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_chaining_and_caching.py .............................. 500s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_check_indexer.py ....................s.... 501s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_coercion.py ..........xxxxxxx...............................................................xx............................................xxxx....x............................................................xxxxx..................xx............................................................................................................................................................................................................x 501s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_datetime.py .........ss 501s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_floats.py ............................................................................................................................................... 501s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_iat.py ..... 501s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_iloc.py .................................................................................................................................................................................................................. 501s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_indexers.py ...... 503s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_indexing.py ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 506s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_loc.py .............................................................................................................................x...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s...................................................................................................................................................................................................................................................................................................................................................................s.................................... 506s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_na_indexing.py .............................................................................................................................................................................................................................................................................. 506s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_partial.py .................................... 506s ../../../usr/lib/python3/dist-packages/pandas/tests/indexing/test_scalar.py ...................................... 506s 506s =============================== warnings summary =============================== 506s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 506s /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-y6sojn6b' 506s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 506s 506s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 506s /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-skphd2ou' 506s session.config.cache.set(STEPWISE_CACHE_DIR, []) 506s 506s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 506s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 506s ============================= slowest 30 durations ============================= 506s 0.31s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_non_unique_memory_error[900000-100000] 506s 0.09s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-1] 506s 0.09s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-3] 506s 0.09s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-2] 506s 0.09s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-4] 506s 0.09s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[a-0] 506s 0.08s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-4] 506s 0.07s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-3] 506s 0.07s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-2] 506s 0.07s call tests/indexing/test_loc.py::TestLocBaseIndependent::test_loc_getitem_range_from_spmatrix[int64-coo_matrix] 506s 0.07s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-1] 506s 0.07s call tests/indexing/multiindex/test_indexing_slow.py::test_multiindex_get_loc[b-0] 506s 0.07s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_implicit_take2 506s 0.07s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_str 506s 0.06s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_setting_entire_column 506s 0.06s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_implicit_take 506s 0.04s call tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_groupby_example 506s 0.02s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_setitem 506s 0.02s call tests/indexing/test_loc.py::TestLocSeries::test_loc_nonunique_masked_index 506s 0.02s teardown tests/indexing/test_scalar.py::TestMultiIndexScalar::test_multiindex_at_get_one_level 506s 0.02s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_getitem 506s 0.01s call tests/indexing/multiindex/test_setitem.py::TestMultiIndexSetItem::test_setitem_multiindex3 506s 0.01s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_per_axis_per_level_doc_examples 506s 0.01s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_loc_axis_arguments 506s 0.01s call tests/indexing/test_loc.py::TestLocCallable::test_frame_loc_setitem_callable 506s 0.01s call tests/indexing/test_chaining_and_caching.py::TestChaining::test_detect_chained_assignment_false_positives 506s 0.01s call tests/indexing/multiindex/test_slice.py::TestMultiIndexSlicers::test_multiindex_slicers_non_unique 506s 0.01s call tests/indexing/test_categorical.py::TestCategoricalIndex::test_loc_getitem_with_non_string_categories[False-idx_values26] 506s 0.01s call tests/indexing/test_indexing.py::TestMisc::test_rhs_alignment 506s 0.01s call tests/indexing/test_categorical.py::TestCategoricalIndex::test_ix_categorical_index_non_unique[False] 506s =========== 4360 passed, 6 skipped, 23 xfailed, 2 warnings in 10.41s =========== 507s rdjoqkol test state = true 507s + echo 'rdjoqkol test state = true' 507s + for TEST_SUBSET in $modpath/tests/* 507s + echo /usr/lib/python3/dist-packages/pandas/tests/interchange 507s + grep -q -e __pycache__ 507s + PANDAS_CI=1 507s + LC_ALL=C.UTF-8 507s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/interchange 507s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 507s 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" 507s 507s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 507s ============================= test session starts ============================== 507s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 507s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 507s rootdir: /usr/lib/python3/dist-packages/pandas 507s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 507s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 507s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 507s collected 140 items 507s 508s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_impl.py ..sssssssss..............sssss........s..s..ssssssssssssssssssssssssssssssss. 508s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_spec_conformance.py ................ 508s ../../../usr/lib/python3/dist-packages/pandas/tests/interchange/test_utils.py ................sssssssssssssssssssssssssssssss 508s 508s =============================== warnings summary =============================== 508s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 508s /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-ba4ifc90' 508s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 508s 508s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 508s /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-ftbnak0y' 508s session.config.cache.set(STEPWISE_CACHE_DIR, []) 508s 508s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 508s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 508s ============================= slowest 30 durations ============================= 508s 0.01s call tests/interchange/test_impl.py::test_dataframe[4] 508s 0.01s call tests/interchange/test_impl.py::test_dataframe[3] 508s 0.01s call tests/interchange/test_impl.py::test_dataframe[0] 508s 508s (27 durations < 0.005s hidden. Use -vv to show these durations.) 508s ================== 61 passed, 79 skipped, 2 warnings in 0.36s ================== 508s rdjoqkol test state = true 508s + echo 'rdjoqkol test state = true' 508s + for TEST_SUBSET in $modpath/tests/* 508s + echo /usr/lib/python3/dist-packages/pandas/tests/internals 508s + grep -q -e __pycache__ 508s + PANDAS_CI=1 508s + LC_ALL=C.UTF-8 508s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/internals 508s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 508s 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" 508s 508s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 509s ============================= test session starts ============================== 509s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 509s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 509s rootdir: /usr/lib/python3/dist-packages/pandas 509s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 509s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 509s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 509s collected 257 items 509s 509s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_api.py ......... 509s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_internals.py .................................................................................................................................................................................................................................................... 510s ../../../usr/lib/python3/dist-packages/pandas/tests/internals/test_managers.py .... 510s 510s =============================== warnings summary =============================== 510s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 510s /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-6jjxoonf' 510s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 510s 510s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 510s /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-rkx378_2' 510s session.config.cache.set(STEPWISE_CACHE_DIR, []) 510s 510s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 510s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 510s ============================= slowest 30 durations ============================= 510s 0.31s call tests/internals/test_managers.py::test_array_manager_depr_env_var[block] 510s 0.29s call tests/internals/test_managers.py::test_array_manager_depr_env_var[array] 510s 0.01s call tests/internals/test_internals.py::TestCanHoldElement::test_interval_can_hold_element[1-int64] 510s 510s (27 durations < 0.005s hidden. Use -vv to show these durations.) 510s ======================= 257 passed, 2 warnings in 1.33s ======================== 510s + echo 'rdjoqkol test state = true' 510s rdjoqkol test state = true 510s + for TEST_SUBSET in $modpath/tests/* 510s + echo /usr/lib/python3/dist-packages/pandas/tests/io 510s + grep -q -e __pycache__ 510s + PANDAS_CI=1 510s + LC_ALL=C.UTF-8 510s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/io 510s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 510s 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" 510s 510s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 518s ============================= test session starts ============================== 518s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 518s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 518s rootdir: /usr/lib/python3/dist-packages/pandas 518s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 518s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 518s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 518s collected 15519 items / 201 deselected / 2 skipped / 15318 selected 518s 518s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odf.py ..... 518s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_odswriter.py .......... 518s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_openpyxl.py ...................................................... 529s ../../../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.sssssFFFFFFsFsssssssssssssssssssssssssssssss......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 531s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_style.py ...................................................................................................................................s 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_writers.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlrd.py ....... 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_xlsxwriter.py ..... 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_bar.py ..........................................................................................................................s 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_exceptions.py ... 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_format.py ......................................................................................................... 540s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_highlight.py ................................................................................................ 541s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_html.py ........................................................................................... 541s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_matplotlib.py ........................................................... 541s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_non_unique.py ......... 542s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_style.py ................................................................................................................................................................................................. 542s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_latex.py ............................................................................................................................................................ 542s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_to_string.py ..... 542s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/style/test_tooltip.py .... 542s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_console.py ........... 542s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_css.py ............................................................................................... 542s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_eng_formatting.py ....... 543s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_format.py .................................................................................................................................................................................. 543s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_ipython_compat.py ss..s 543s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_printing.py ......... 543s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_csv.py ..........s.................................................................................. 544s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_excel.py .......................................................................................................................................................................................................................................................................................................................................................................................................................... 544s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_html.py .....................................................................................................................................................................................................................................................................................................................................................................s................... 545s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_latex.py ............................................................................................ 545s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_markdown.py .......... 545s ../../../usr/lib/python3/dist-packages/pandas/tests/io/formats/test_to_string.py ...............................................s........................................... 545s ../../../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....... 545s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_deprecated_kwargs.py . 546s ../../../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........................... 546s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_json_table_schema_ext_dtype.py ..................... 546s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_normalize.py ..................................................... 550s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py ...........................................................................................................xxxx................................xxx......................................................................................................................................FFF...............................s........xxxxxxxxxxxxxxxxxx................................................................xx.............s.....x........ssssssssssssssssssssssssssssssss...sssss.s. 550s ../../../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........... 551s ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_ujson.py ................................................................................................................................................................................................................... 551s ../../../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 551s ../../../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 552s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_data_list.py ...s...s...s...s 552s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_decimal.py ......ss...s 553s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_file_buffer_url.py FFFs...s...s...s...s.................................sssssssssss...s...s...s...s...s...s...s...s............ssss.....................sssssss...s...s...s...s 553s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_float.py ...s.......s.....................sss....x.....x...ss 553s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_index.py ......ss......ss...s............ssss...s...s...s...s...s...s...s 554s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_inf.py ......ss......ss...s 554s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_ints.py ...s............ssss...s......ss...s.........sss.........sss......ss......ss...s 554s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_iterator.py ...s...s...s.........sss...s 554s ../../../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 554s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_verbose.py ...s...s 554s ../../../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 556s ../../../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 556s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/dtypes/test_empty.py ...s...s...s...s...s...s...s...s........................ssssssss 557s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_c_parser_only.py .......................................................................... 557s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_comment.py ......ss.........sss...s...s...s..................ssssss......ssxx.s 558s ../../../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 558s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_concatenate_chunks.py ss 559s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_converters.py ...s............ssss...s...s...s......ss...s...s 559s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_dialect.py ...s...s...s......................................................ssssssssssssssssss..................ssssss 559s ../../../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 560s ../../../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 560s ../../../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 560s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_mangle_dupes.py ...s...s...s.........sss.........sss...s...s...s......ss 560s ../../../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 573s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py FFFFFFFFFFFFFFFFssssFFFFFssssssssssssssssss 574s ../../../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 574s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_python_parser_only.py ..................................................................................... 575s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_quoting.py .........sss......ss...s..................ssssss............ssss...............sssss......ss......ss......ss 575s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_read_fwf.py ..........................................................................sss.F 575s ../../../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 575s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_textreader.py ..................................... 576s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_unsupported.py ..........s...s..xs...s 576s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_upcast.py ...........................ssss 576s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_parse_dates.py ......ss...s...s...s............ssss 576s ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/usecols/test_strings.py ...s...s......ss......ss 576s ../../../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 577s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....x................ 578s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_categorical.py ..... 578s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_compat.py .... 578s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_complex.py ......... 578s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_errors.py ................ 582s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................xxxxxxxxx................................................................................................................................... 582s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_keys.py .... 582s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_put.py ...................... 582s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_pytables_missing.py s 582s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_read.py ....................s 582s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_retain_attributes.py ..... 583s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_round_trip.py ..............................s 585s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_select.py ...x.....x............... 587s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................x..................... 587s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_subclass.py .. 587s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_time_series.py .... 587s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_timezones.py .......................................................................... 588s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_byteswap.py .......... 588s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas.py ... 589s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_sas7bdat.py ....................... 589s ../../../usr/lib/python3/dist-packages/pandas/tests/io/sas/test_xport.py ....... 589s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_clipboard.py .......QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-ubuntu' 590s ...............................................................................................................................................................................................................................................................................................................................ssssss.. 590s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_common.py .......................................................s....s........ss.......s.........s.......s......................................... 591s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_compression.py ........................................................................................................................................ 591s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_fsspec.py .........ssssssssss..........s 591s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gbq.py .. 591s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_gcs.py ssssssssssssssssss. 599s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py .........ssssssFFFF............................................FFFF...........................................................................s.................... 610s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py FFFssFFFFFFFssFFFFFFFssFFFFss 610s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_parquet.py .ssss.ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.ssssssss 614s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_pickle.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. 615s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_s3.py .ss 615s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_spss.py .......s.. 627s ../../../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................ 631s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_stata.py ..............................................................................................................................................................................................................................................................................................................................................................................s.................................................................................................................................................................................................................................................... 632s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_to_xml.py ........................................................................s...............................................................ss 636s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py ................................FFF.....................................................s............................................................................s......s......s......s......s......s......s......s......s......s......s......s..s.sss.sss. 636s ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml_dtypes.py .............................................. 636s 636s =================================== FAILURES =================================== 636s ____________ TestReaders.test_read_from_http_url[('xlrd', '.xls')] _____________ 636s 636s self = 636s httpserver = , started 133470494824128)> 636s read_ext = '.xls' 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_read_from_http_url(self, httpserver, read_ext): 636s with open("test1" + read_ext, "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s > url_table = pd.read_excel(httpserver.url) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py:917: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:37447', sheet_name = 0 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s @Appender(_read_excel_doc) 636s def read_excel( 636s io, 636s sheet_name: str | int | list[IntStrT] | None = 0, 636s *, 636s header: int | Sequence[int] | None = 0, 636s names: SequenceNotStr[Hashable] | range | None = None, 636s index_col: int | str | Sequence[int] | None = None, 636s usecols: int 636s | str 636s | Sequence[int] 636s | Sequence[str] 636s | Callable[[str], bool] 636s | None = None, 636s dtype: DtypeArg | None = None, 636s engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb", "calamine"] | None = None, 636s converters: dict[str, Callable] | dict[int, Callable] | None = None, 636s true_values: Iterable[Hashable] | None = None, 636s false_values: Iterable[Hashable] | None = None, 636s skiprows: Sequence[int] | int | Callable[[int], object] | None = None, 636s nrows: int | None = None, 636s na_values=None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool = False, 636s parse_dates: list | dict | bool = False, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: dict[Hashable, str] | str | None = None, 636s thousands: str | None = None, 636s decimal: str = ".", 636s comment: str | None = None, 636s skipfooter: int = 0, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine_kwargs: dict | None = None, 636s ) -> DataFrame | dict[IntStrT, DataFrame]: 636s check_dtype_backend(dtype_backend) 636s should_close = False 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if not isinstance(io, ExcelFile): 636s should_close = True 636s > io = ExcelFile( 636s io, 636s storage_options=storage_options, 636s engine=engine, 636s engine_kwargs=engine_kwargs, 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s path_or_buffer = 'http://127.0.0.1:37447', engine = 'xlrd' 636s storage_options = None, engine_kwargs = {} 636s 636s def __init__( 636s self, 636s path_or_buffer, 636s engine: str | None = None, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if engine is not None and engine not in self._engines: 636s raise ValueError(f"Unknown engine: {engine}") 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(path_or_buffer, bytes): 636s path_or_buffer = BytesIO(path_or_buffer) 636s warnings.warn( 636s "Passing bytes to 'read_excel' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "byte string, wrap it in a `BytesIO` object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Could be a str, ExcelFile, Book, etc. 636s self.io = path_or_buffer 636s # Always a string 636s self._io = stringify_path(path_or_buffer) 636s 636s # Determine xlrd version if installed 636s if import_optional_dependency("xlrd", errors="ignore") is None: 636s xlrd_version = None 636s else: 636s import xlrd 636s 636s xlrd_version = Version(get_version(xlrd)) 636s 636s if engine is None: 636s # Only determine ext if it is needed 636s ext: str | None 636s if xlrd_version is not None and isinstance(path_or_buffer, xlrd.Book): 636s ext = "xls" 636s else: 636s ext = inspect_excel_format( 636s content_or_path=path_or_buffer, storage_options=storage_options 636s ) 636s if ext is None: 636s raise ValueError( 636s "Excel file format cannot be determined, you must specify " 636s "an engine manually." 636s ) 636s 636s engine = config.get_option(f"io.excel.{ext}.reader", silent=True) 636s if engine == "auto": 636s engine = get_default_engine(ext, mode="reader") 636s 636s assert engine is not None 636s self.engine = engine 636s self.storage_options = storage_options 636s 636s > self._reader = self._engines[engine]( 636s self._io, 636s storage_options=storage_options, 636s engine_kwargs=engine_kwargs, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:1567: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:37447', storage_options = None 636s engine_kwargs = {} 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def __init__( 636s self, 636s filepath_or_buffer, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s """ 636s Reader using xlrd engine. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : str, path object or Workbook 636s Object to be parsed. 636s {storage_options} 636s engine_kwargs : dict, optional 636s Arbitrary keyword arguments passed to excel engine. 636s """ 636s err_msg = "Install xlrd >= 2.0.1 for xls Excel support" 636s import_optional_dependency("xlrd", extra=err_msg) 636s > super().__init__( 636s filepath_or_buffer, 636s storage_options=storage_options, 636s engine_kwargs=engine_kwargs, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_xlrd.py:46: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:37447', storage_options = None 636s engine_kwargs = {} 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(filepath_or_buffer, bytes): 636s filepath_or_buffer = BytesIO(filepath_or_buffer) 636s 636s self.handles = IOHandles( 636s handle=filepath_or_buffer, compression={"method": None} 636s ) 636s if not isinstance(filepath_or_buffer, (ExcelFile, self._workbook_class)): 636s > self.handles = get_handle( 636s filepath_or_buffer, "rb", storage_options=storage_options, is_text=False 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:563: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:37447', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:37447', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s __________ TestReaders.test_read_from_http_url[('openpyxl', '.xlsx')] __________ 636s 636s self = 636s httpserver = , started 133470486431424)> 636s read_ext = '.xlsx' 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_read_from_http_url(self, httpserver, read_ext): 636s with open("test1" + read_ext, "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s > url_table = pd.read_excel(httpserver.url) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py:917: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:46647', sheet_name = 0 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s @Appender(_read_excel_doc) 636s def read_excel( 636s io, 636s sheet_name: str | int | list[IntStrT] | None = 0, 636s *, 636s header: int | Sequence[int] | None = 0, 636s names: SequenceNotStr[Hashable] | range | None = None, 636s index_col: int | str | Sequence[int] | None = None, 636s usecols: int 636s | str 636s | Sequence[int] 636s | Sequence[str] 636s | Callable[[str], bool] 636s | None = None, 636s dtype: DtypeArg | None = None, 636s engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb", "calamine"] | None = None, 636s converters: dict[str, Callable] | dict[int, Callable] | None = None, 636s true_values: Iterable[Hashable] | None = None, 636s false_values: Iterable[Hashable] | None = None, 636s skiprows: Sequence[int] | int | Callable[[int], object] | None = None, 636s nrows: int | None = None, 636s na_values=None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool = False, 636s parse_dates: list | dict | bool = False, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: dict[Hashable, str] | str | None = None, 636s thousands: str | None = None, 636s decimal: str = ".", 636s comment: str | None = None, 636s skipfooter: int = 0, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine_kwargs: dict | None = None, 636s ) -> DataFrame | dict[IntStrT, DataFrame]: 636s check_dtype_backend(dtype_backend) 636s should_close = False 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if not isinstance(io, ExcelFile): 636s should_close = True 636s > io = ExcelFile( 636s io, 636s storage_options=storage_options, 636s engine=engine, 636s engine_kwargs=engine_kwargs, 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s path_or_buffer = 'http://127.0.0.1:46647', engine = 'openpyxl' 636s storage_options = None, engine_kwargs = {} 636s 636s def __init__( 636s self, 636s path_or_buffer, 636s engine: str | None = None, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if engine is not None and engine not in self._engines: 636s raise ValueError(f"Unknown engine: {engine}") 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(path_or_buffer, bytes): 636s path_or_buffer = BytesIO(path_or_buffer) 636s warnings.warn( 636s "Passing bytes to 'read_excel' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "byte string, wrap it in a `BytesIO` object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Could be a str, ExcelFile, Book, etc. 636s self.io = path_or_buffer 636s # Always a string 636s self._io = stringify_path(path_or_buffer) 636s 636s # Determine xlrd version if installed 636s if import_optional_dependency("xlrd", errors="ignore") is None: 636s xlrd_version = None 636s else: 636s import xlrd 636s 636s xlrd_version = Version(get_version(xlrd)) 636s 636s if engine is None: 636s # Only determine ext if it is needed 636s ext: str | None 636s if xlrd_version is not None and isinstance(path_or_buffer, xlrd.Book): 636s ext = "xls" 636s else: 636s ext = inspect_excel_format( 636s content_or_path=path_or_buffer, storage_options=storage_options 636s ) 636s if ext is None: 636s raise ValueError( 636s "Excel file format cannot be determined, you must specify " 636s "an engine manually." 636s ) 636s 636s engine = config.get_option(f"io.excel.{ext}.reader", silent=True) 636s if engine == "auto": 636s engine = get_default_engine(ext, mode="reader") 636s 636s assert engine is not None 636s self.engine = engine 636s self.storage_options = storage_options 636s 636s > self._reader = self._engines[engine]( 636s self._io, 636s storage_options=storage_options, 636s engine_kwargs=engine_kwargs, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:1567: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:46647', storage_options = None 636s engine_kwargs = {} 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def __init__( 636s self, 636s filepath_or_buffer: FilePath | ReadBuffer[bytes], 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s """ 636s Reader using openpyxl engine. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : str, path object or Workbook 636s Object to be parsed. 636s {storage_options} 636s engine_kwargs : dict, optional 636s Arbitrary keyword arguments passed to excel engine. 636s """ 636s import_optional_dependency("openpyxl") 636s > super().__init__( 636s filepath_or_buffer, 636s storage_options=storage_options, 636s engine_kwargs=engine_kwargs, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_openpyxl.py:553: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:46647', storage_options = None 636s engine_kwargs = {} 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(filepath_or_buffer, bytes): 636s filepath_or_buffer = BytesIO(filepath_or_buffer) 636s 636s self.handles = IOHandles( 636s handle=filepath_or_buffer, compression={"method": None} 636s ) 636s if not isinstance(filepath_or_buffer, (ExcelFile, self._workbook_class)): 636s > self.handles = get_handle( 636s filepath_or_buffer, "rb", storage_options=storage_options, is_text=False 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:563: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:46647', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46647', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s __________ TestReaders.test_read_from_http_url[('openpyxl', '.xlsm')] __________ 636s 636s self = 636s httpserver = , started 133470494824128)> 636s read_ext = '.xlsm' 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_read_from_http_url(self, httpserver, read_ext): 636s with open("test1" + read_ext, "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s > url_table = pd.read_excel(httpserver.url) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py:917: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:34563', sheet_name = 0 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s @Appender(_read_excel_doc) 636s def read_excel( 636s io, 636s sheet_name: str | int | list[IntStrT] | None = 0, 636s *, 636s header: int | Sequence[int] | None = 0, 636s names: SequenceNotStr[Hashable] | range | None = None, 636s index_col: int | str | Sequence[int] | None = None, 636s usecols: int 636s | str 636s | Sequence[int] 636s | Sequence[str] 636s | Callable[[str], bool] 636s | None = None, 636s dtype: DtypeArg | None = None, 636s engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb", "calamine"] | None = None, 636s converters: dict[str, Callable] | dict[int, Callable] | None = None, 636s true_values: Iterable[Hashable] | None = None, 636s false_values: Iterable[Hashable] | None = None, 636s skiprows: Sequence[int] | int | Callable[[int], object] | None = None, 636s nrows: int | None = None, 636s na_values=None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool = False, 636s parse_dates: list | dict | bool = False, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: dict[Hashable, str] | str | None = None, 636s thousands: str | None = None, 636s decimal: str = ".", 636s comment: str | None = None, 636s skipfooter: int = 0, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine_kwargs: dict | None = None, 636s ) -> DataFrame | dict[IntStrT, DataFrame]: 636s check_dtype_backend(dtype_backend) 636s should_close = False 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if not isinstance(io, ExcelFile): 636s should_close = True 636s > io = ExcelFile( 636s io, 636s storage_options=storage_options, 636s engine=engine, 636s engine_kwargs=engine_kwargs, 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s path_or_buffer = 'http://127.0.0.1:34563', engine = 'openpyxl' 636s storage_options = None, engine_kwargs = {} 636s 636s def __init__( 636s self, 636s path_or_buffer, 636s engine: str | None = None, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if engine is not None and engine not in self._engines: 636s raise ValueError(f"Unknown engine: {engine}") 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(path_or_buffer, bytes): 636s path_or_buffer = BytesIO(path_or_buffer) 636s warnings.warn( 636s "Passing bytes to 'read_excel' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "byte string, wrap it in a `BytesIO` object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Could be a str, ExcelFile, Book, etc. 636s self.io = path_or_buffer 636s # Always a string 636s self._io = stringify_path(path_or_buffer) 636s 636s # Determine xlrd version if installed 636s if import_optional_dependency("xlrd", errors="ignore") is None: 636s xlrd_version = None 636s else: 636s import xlrd 636s 636s xlrd_version = Version(get_version(xlrd)) 636s 636s if engine is None: 636s # Only determine ext if it is needed 636s ext: str | None 636s if xlrd_version is not None and isinstance(path_or_buffer, xlrd.Book): 636s ext = "xls" 636s else: 636s ext = inspect_excel_format( 636s content_or_path=path_or_buffer, storage_options=storage_options 636s ) 636s if ext is None: 636s raise ValueError( 636s "Excel file format cannot be determined, you must specify " 636s "an engine manually." 636s ) 636s 636s engine = config.get_option(f"io.excel.{ext}.reader", silent=True) 636s if engine == "auto": 636s engine = get_default_engine(ext, mode="reader") 636s 636s assert engine is not None 636s self.engine = engine 636s self.storage_options = storage_options 636s 636s > self._reader = self._engines[engine]( 636s self._io, 636s storage_options=storage_options, 636s engine_kwargs=engine_kwargs, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:1567: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:34563', storage_options = None 636s engine_kwargs = {} 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def __init__( 636s self, 636s filepath_or_buffer: FilePath | ReadBuffer[bytes], 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s """ 636s Reader using openpyxl engine. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : str, path object or Workbook 636s Object to be parsed. 636s {storage_options} 636s engine_kwargs : dict, optional 636s Arbitrary keyword arguments passed to excel engine. 636s """ 636s import_optional_dependency("openpyxl") 636s > super().__init__( 636s filepath_or_buffer, 636s storage_options=storage_options, 636s engine_kwargs=engine_kwargs, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_openpyxl.py:553: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:34563', storage_options = None 636s engine_kwargs = {} 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(filepath_or_buffer, bytes): 636s filepath_or_buffer = BytesIO(filepath_or_buffer) 636s 636s self.handles = IOHandles( 636s handle=filepath_or_buffer, compression={"method": None} 636s ) 636s if not isinstance(filepath_or_buffer, (ExcelFile, self._workbook_class)): 636s > self.handles = get_handle( 636s filepath_or_buffer, "rb", storage_options=storage_options, is_text=False 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:563: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:34563', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:34563', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________ TestReaders.test_read_from_http_url[(None, '.xls')] ______________ 636s 636s self = 636s httpserver = , started 133470486431424)> 636s read_ext = '.xls' 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_read_from_http_url(self, httpserver, read_ext): 636s with open("test1" + read_ext, "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s > url_table = pd.read_excel(httpserver.url) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py:917: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:34929', sheet_name = 0 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s @Appender(_read_excel_doc) 636s def read_excel( 636s io, 636s sheet_name: str | int | list[IntStrT] | None = 0, 636s *, 636s header: int | Sequence[int] | None = 0, 636s names: SequenceNotStr[Hashable] | range | None = None, 636s index_col: int | str | Sequence[int] | None = None, 636s usecols: int 636s | str 636s | Sequence[int] 636s | Sequence[str] 636s | Callable[[str], bool] 636s | None = None, 636s dtype: DtypeArg | None = None, 636s engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb", "calamine"] | None = None, 636s converters: dict[str, Callable] | dict[int, Callable] | None = None, 636s true_values: Iterable[Hashable] | None = None, 636s false_values: Iterable[Hashable] | None = None, 636s skiprows: Sequence[int] | int | Callable[[int], object] | None = None, 636s nrows: int | None = None, 636s na_values=None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool = False, 636s parse_dates: list | dict | bool = False, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: dict[Hashable, str] | str | None = None, 636s thousands: str | None = None, 636s decimal: str = ".", 636s comment: str | None = None, 636s skipfooter: int = 0, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine_kwargs: dict | None = None, 636s ) -> DataFrame | dict[IntStrT, DataFrame]: 636s check_dtype_backend(dtype_backend) 636s should_close = False 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if not isinstance(io, ExcelFile): 636s should_close = True 636s > io = ExcelFile( 636s io, 636s storage_options=storage_options, 636s engine=engine, 636s engine_kwargs=engine_kwargs, 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s path_or_buffer = 'http://127.0.0.1:34929', engine = None, storage_options = None 636s engine_kwargs = {} 636s 636s def __init__( 636s self, 636s path_or_buffer, 636s engine: str | None = None, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if engine is not None and engine not in self._engines: 636s raise ValueError(f"Unknown engine: {engine}") 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(path_or_buffer, bytes): 636s path_or_buffer = BytesIO(path_or_buffer) 636s warnings.warn( 636s "Passing bytes to 'read_excel' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "byte string, wrap it in a `BytesIO` object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Could be a str, ExcelFile, Book, etc. 636s self.io = path_or_buffer 636s # Always a string 636s self._io = stringify_path(path_or_buffer) 636s 636s # Determine xlrd version if installed 636s if import_optional_dependency("xlrd", errors="ignore") is None: 636s xlrd_version = None 636s else: 636s import xlrd 636s 636s xlrd_version = Version(get_version(xlrd)) 636s 636s if engine is None: 636s # Only determine ext if it is needed 636s ext: str | None 636s if xlrd_version is not None and isinstance(path_or_buffer, xlrd.Book): 636s ext = "xls" 636s else: 636s > ext = inspect_excel_format( 636s content_or_path=path_or_buffer, storage_options=storage_options 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:1550: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s content_or_path = 'http://127.0.0.1:34929', storage_options = None 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def inspect_excel_format( 636s content_or_path: FilePath | ReadBuffer[bytes], 636s storage_options: StorageOptions | None = None, 636s ) -> str | None: 636s """ 636s Inspect the path or content of an excel file and get its format. 636s 636s Adopted from xlrd: https://github.com/python-excel/xlrd. 636s 636s Parameters 636s ---------- 636s content_or_path : str or file-like object 636s Path to file or content of file to inspect. May be a URL. 636s {storage_options} 636s 636s Returns 636s ------- 636s str or None 636s Format of file if it can be determined. 636s 636s Raises 636s ------ 636s ValueError 636s If resulting stream is empty. 636s BadZipFile 636s If resulting stream does not have an XLS signature and is not a valid zipfile. 636s """ 636s if isinstance(content_or_path, bytes): 636s content_or_path = BytesIO(content_or_path) 636s 636s > with get_handle( 636s content_or_path, "rb", storage_options=storage_options, is_text=False 636s ) as handle: 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:1402: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:34929', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:34929', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________ TestReaders.test_read_from_http_url[(None, '.xlsx')] _____________ 636s 636s self = 636s httpserver = , started 133470403688128)> 636s read_ext = '.xlsx' 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_read_from_http_url(self, httpserver, read_ext): 636s with open("test1" + read_ext, "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s > url_table = pd.read_excel(httpserver.url) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py:917: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:43055', sheet_name = 0 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s @Appender(_read_excel_doc) 636s def read_excel( 636s io, 636s sheet_name: str | int | list[IntStrT] | None = 0, 636s *, 636s header: int | Sequence[int] | None = 0, 636s names: SequenceNotStr[Hashable] | range | None = None, 636s index_col: int | str | Sequence[int] | None = None, 636s usecols: int 636s | str 636s | Sequence[int] 636s | Sequence[str] 636s | Callable[[str], bool] 636s | None = None, 636s dtype: DtypeArg | None = None, 636s engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb", "calamine"] | None = None, 636s converters: dict[str, Callable] | dict[int, Callable] | None = None, 636s true_values: Iterable[Hashable] | None = None, 636s false_values: Iterable[Hashable] | None = None, 636s skiprows: Sequence[int] | int | Callable[[int], object] | None = None, 636s nrows: int | None = None, 636s na_values=None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool = False, 636s parse_dates: list | dict | bool = False, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: dict[Hashable, str] | str | None = None, 636s thousands: str | None = None, 636s decimal: str = ".", 636s comment: str | None = None, 636s skipfooter: int = 0, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine_kwargs: dict | None = None, 636s ) -> DataFrame | dict[IntStrT, DataFrame]: 636s check_dtype_backend(dtype_backend) 636s should_close = False 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if not isinstance(io, ExcelFile): 636s should_close = True 636s > io = ExcelFile( 636s io, 636s storage_options=storage_options, 636s engine=engine, 636s engine_kwargs=engine_kwargs, 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s path_or_buffer = 'http://127.0.0.1:43055', engine = None, storage_options = None 636s engine_kwargs = {} 636s 636s def __init__( 636s self, 636s path_or_buffer, 636s engine: str | None = None, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if engine is not None and engine not in self._engines: 636s raise ValueError(f"Unknown engine: {engine}") 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(path_or_buffer, bytes): 636s path_or_buffer = BytesIO(path_or_buffer) 636s warnings.warn( 636s "Passing bytes to 'read_excel' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "byte string, wrap it in a `BytesIO` object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Could be a str, ExcelFile, Book, etc. 636s self.io = path_or_buffer 636s # Always a string 636s self._io = stringify_path(path_or_buffer) 636s 636s # Determine xlrd version if installed 636s if import_optional_dependency("xlrd", errors="ignore") is None: 636s xlrd_version = None 636s else: 636s import xlrd 636s 636s xlrd_version = Version(get_version(xlrd)) 636s 636s if engine is None: 636s # Only determine ext if it is needed 636s ext: str | None 636s if xlrd_version is not None and isinstance(path_or_buffer, xlrd.Book): 636s ext = "xls" 636s else: 636s > ext = inspect_excel_format( 636s content_or_path=path_or_buffer, storage_options=storage_options 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:1550: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s content_or_path = 'http://127.0.0.1:43055', storage_options = None 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def inspect_excel_format( 636s content_or_path: FilePath | ReadBuffer[bytes], 636s storage_options: StorageOptions | None = None, 636s ) -> str | None: 636s """ 636s Inspect the path or content of an excel file and get its format. 636s 636s Adopted from xlrd: https://github.com/python-excel/xlrd. 636s 636s Parameters 636s ---------- 636s content_or_path : str or file-like object 636s Path to file or content of file to inspect. May be a URL. 636s {storage_options} 636s 636s Returns 636s ------- 636s str or None 636s Format of file if it can be determined. 636s 636s Raises 636s ------ 636s ValueError 636s If resulting stream is empty. 636s BadZipFile 636s If resulting stream does not have an XLS signature and is not a valid zipfile. 636s """ 636s if isinstance(content_or_path, bytes): 636s content_or_path = BytesIO(content_or_path) 636s 636s > with get_handle( 636s content_or_path, "rb", storage_options=storage_options, is_text=False 636s ) as handle: 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:1402: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:43055', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43055', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________ TestReaders.test_read_from_http_url[(None, '.xlsm')] _____________ 636s 636s self = 636s httpserver = , started 133470486431424)> 636s read_ext = '.xlsm' 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_read_from_http_url(self, httpserver, read_ext): 636s with open("test1" + read_ext, "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s > url_table = pd.read_excel(httpserver.url) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py:917: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:45217', sheet_name = 0 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s @Appender(_read_excel_doc) 636s def read_excel( 636s io, 636s sheet_name: str | int | list[IntStrT] | None = 0, 636s *, 636s header: int | Sequence[int] | None = 0, 636s names: SequenceNotStr[Hashable] | range | None = None, 636s index_col: int | str | Sequence[int] | None = None, 636s usecols: int 636s | str 636s | Sequence[int] 636s | Sequence[str] 636s | Callable[[str], bool] 636s | None = None, 636s dtype: DtypeArg | None = None, 636s engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb", "calamine"] | None = None, 636s converters: dict[str, Callable] | dict[int, Callable] | None = None, 636s true_values: Iterable[Hashable] | None = None, 636s false_values: Iterable[Hashable] | None = None, 636s skiprows: Sequence[int] | int | Callable[[int], object] | None = None, 636s nrows: int | None = None, 636s na_values=None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool = False, 636s parse_dates: list | dict | bool = False, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: dict[Hashable, str] | str | None = None, 636s thousands: str | None = None, 636s decimal: str = ".", 636s comment: str | None = None, 636s skipfooter: int = 0, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine_kwargs: dict | None = None, 636s ) -> DataFrame | dict[IntStrT, DataFrame]: 636s check_dtype_backend(dtype_backend) 636s should_close = False 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if not isinstance(io, ExcelFile): 636s should_close = True 636s > io = ExcelFile( 636s io, 636s storage_options=storage_options, 636s engine=engine, 636s engine_kwargs=engine_kwargs, 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s path_or_buffer = 'http://127.0.0.1:45217', engine = None, storage_options = None 636s engine_kwargs = {} 636s 636s def __init__( 636s self, 636s path_or_buffer, 636s engine: str | None = None, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if engine is not None and engine not in self._engines: 636s raise ValueError(f"Unknown engine: {engine}") 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(path_or_buffer, bytes): 636s path_or_buffer = BytesIO(path_or_buffer) 636s warnings.warn( 636s "Passing bytes to 'read_excel' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "byte string, wrap it in a `BytesIO` object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Could be a str, ExcelFile, Book, etc. 636s self.io = path_or_buffer 636s # Always a string 636s self._io = stringify_path(path_or_buffer) 636s 636s # Determine xlrd version if installed 636s if import_optional_dependency("xlrd", errors="ignore") is None: 636s xlrd_version = None 636s else: 636s import xlrd 636s 636s xlrd_version = Version(get_version(xlrd)) 636s 636s if engine is None: 636s # Only determine ext if it is needed 636s ext: str | None 636s if xlrd_version is not None and isinstance(path_or_buffer, xlrd.Book): 636s ext = "xls" 636s else: 636s > ext = inspect_excel_format( 636s content_or_path=path_or_buffer, storage_options=storage_options 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:1550: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s content_or_path = 'http://127.0.0.1:45217', storage_options = None 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def inspect_excel_format( 636s content_or_path: FilePath | ReadBuffer[bytes], 636s storage_options: StorageOptions | None = None, 636s ) -> str | None: 636s """ 636s Inspect the path or content of an excel file and get its format. 636s 636s Adopted from xlrd: https://github.com/python-excel/xlrd. 636s 636s Parameters 636s ---------- 636s content_or_path : str or file-like object 636s Path to file or content of file to inspect. May be a URL. 636s {storage_options} 636s 636s Returns 636s ------- 636s str or None 636s Format of file if it can be determined. 636s 636s Raises 636s ------ 636s ValueError 636s If resulting stream is empty. 636s BadZipFile 636s If resulting stream does not have an XLS signature and is not a valid zipfile. 636s """ 636s if isinstance(content_or_path, bytes): 636s content_or_path = BytesIO(content_or_path) 636s 636s > with get_handle( 636s content_or_path, "rb", storage_options=storage_options, is_text=False 636s ) as handle: 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:1402: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:45217', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45217', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________ TestReaders.test_read_from_http_url[('odf', '.ods')] _____________ 636s 636s self = 636s httpserver = , started 133470395295424)> 636s read_ext = '.ods' 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_read_from_http_url(self, httpserver, read_ext): 636s with open("test1" + read_ext, "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s > url_table = pd.read_excel(httpserver.url) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py:917: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:33019', sheet_name = 0 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s @Appender(_read_excel_doc) 636s def read_excel( 636s io, 636s sheet_name: str | int | list[IntStrT] | None = 0, 636s *, 636s header: int | Sequence[int] | None = 0, 636s names: SequenceNotStr[Hashable] | range | None = None, 636s index_col: int | str | Sequence[int] | None = None, 636s usecols: int 636s | str 636s | Sequence[int] 636s | Sequence[str] 636s | Callable[[str], bool] 636s | None = None, 636s dtype: DtypeArg | None = None, 636s engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb", "calamine"] | None = None, 636s converters: dict[str, Callable] | dict[int, Callable] | None = None, 636s true_values: Iterable[Hashable] | None = None, 636s false_values: Iterable[Hashable] | None = None, 636s skiprows: Sequence[int] | int | Callable[[int], object] | None = None, 636s nrows: int | None = None, 636s na_values=None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool = False, 636s parse_dates: list | dict | bool = False, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: dict[Hashable, str] | str | None = None, 636s thousands: str | None = None, 636s decimal: str = ".", 636s comment: str | None = None, 636s skipfooter: int = 0, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine_kwargs: dict | None = None, 636s ) -> DataFrame | dict[IntStrT, DataFrame]: 636s check_dtype_backend(dtype_backend) 636s should_close = False 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if not isinstance(io, ExcelFile): 636s should_close = True 636s > io = ExcelFile( 636s io, 636s storage_options=storage_options, 636s engine=engine, 636s engine_kwargs=engine_kwargs, 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s path_or_buffer = 'http://127.0.0.1:33019', engine = 'odf' 636s storage_options = None, engine_kwargs = {} 636s 636s def __init__( 636s self, 636s path_or_buffer, 636s engine: str | None = None, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s if engine is not None and engine not in self._engines: 636s raise ValueError(f"Unknown engine: {engine}") 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(path_or_buffer, bytes): 636s path_or_buffer = BytesIO(path_or_buffer) 636s warnings.warn( 636s "Passing bytes to 'read_excel' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "byte string, wrap it in a `BytesIO` object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Could be a str, ExcelFile, Book, etc. 636s self.io = path_or_buffer 636s # Always a string 636s self._io = stringify_path(path_or_buffer) 636s 636s # Determine xlrd version if installed 636s if import_optional_dependency("xlrd", errors="ignore") is None: 636s xlrd_version = None 636s else: 636s import xlrd 636s 636s xlrd_version = Version(get_version(xlrd)) 636s 636s if engine is None: 636s # Only determine ext if it is needed 636s ext: str | None 636s if xlrd_version is not None and isinstance(path_or_buffer, xlrd.Book): 636s ext = "xls" 636s else: 636s ext = inspect_excel_format( 636s content_or_path=path_or_buffer, storage_options=storage_options 636s ) 636s if ext is None: 636s raise ValueError( 636s "Excel file format cannot be determined, you must specify " 636s "an engine manually." 636s ) 636s 636s engine = config.get_option(f"io.excel.{ext}.reader", silent=True) 636s if engine == "auto": 636s engine = get_default_engine(ext, mode="reader") 636s 636s assert engine is not None 636s self.engine = engine 636s self.storage_options = storage_options 636s 636s > self._reader = self._engines[engine]( 636s self._io, 636s storage_options=storage_options, 636s engine_kwargs=engine_kwargs, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:1567: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:33019', storage_options = None 636s engine_kwargs = {} 636s 636s def __init__( 636s self, 636s filepath_or_buffer: FilePath | ReadBuffer[bytes], 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s """ 636s Read tables out of OpenDocument formatted files. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : str, path to be parsed or 636s an open readable stream. 636s {storage_options} 636s engine_kwargs : dict, optional 636s Arbitrary keyword arguments passed to excel engine. 636s """ 636s import_optional_dependency("odf") 636s > super().__init__( 636s filepath_or_buffer, 636s storage_options=storage_options, 636s engine_kwargs=engine_kwargs, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_odfreader.py:50: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:33019', storage_options = None 636s engine_kwargs = {} 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s storage_options: StorageOptions | None = None, 636s engine_kwargs: dict | None = None, 636s ) -> None: 636s if engine_kwargs is None: 636s engine_kwargs = {} 636s 636s # First argument can also be bytes, so create a buffer 636s if isinstance(filepath_or_buffer, bytes): 636s filepath_or_buffer = BytesIO(filepath_or_buffer) 636s 636s self.handles = IOHandles( 636s handle=filepath_or_buffer, compression={"method": None} 636s ) 636s if not isinstance(filepath_or_buffer, (ExcelFile, self._workbook_class)): 636s > self.handles = get_handle( 636s filepath_or_buffer, "rb", storage_options=storage_options, is_text=False 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/excel/_base.py:563: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:33019', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:33019', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______________ TestPandasContainer.test_url[created_at-dtype0] ________________ 636s 636s self = 636s field = 'created_at', dtype = datetime64[ns, UTC] 636s httpserver = , started 133470403688128)> 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize( 636s "field,dtype", 636s [ 636s ["created_at", pd.DatetimeTZDtype(tz="UTC")], 636s ["closed_at", "datetime64[ns]"], 636s ["updated_at", pd.DatetimeTZDtype(tz="UTC")], 636s ], 636s ) 636s def test_url(self, field, dtype, httpserver): 636s data = '{"created_at": ["2023-06-23T18:21:36Z"], "closed_at": ["2023-06-23T18:21:36"], "updated_at": ["2023-06-23T18:21:36Z"]}\n' # noqa: E501 636s httpserver.serve_content(content=data) 636s > result = read_json(httpserver.url, convert_dates=True) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py:1079: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:41883' 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "path_or_buf", 636s ) 636s def read_json( 636s path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], 636s *, 636s orient: str | None = None, 636s typ: Literal["frame", "series"] = "frame", 636s dtype: DtypeArg | None = None, 636s convert_axes: bool | None = None, 636s convert_dates: bool | list[str] = True, 636s keep_default_dates: bool = True, 636s precise_float: bool = False, 636s date_unit: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s lines: bool = False, 636s chunksize: int | None = None, 636s compression: CompressionOptions = "infer", 636s nrows: int | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> DataFrame | Series | JsonReader: 636s """ 636s Convert a JSON string to pandas object. 636s 636s Parameters 636s ---------- 636s path_or_buf : a valid JSON str, path object or file-like object 636s Any valid string path is acceptable. The string could be a URL. Valid 636s URL schemes include http, ftp, s3, and file. For file URLs, a host is 636s expected. A local file could be: 636s ``file://localhost/path/to/table.json``. 636s 636s If you want to pass in a path object, pandas accepts any 636s ``os.PathLike``. 636s 636s By file-like object, we refer to objects with a ``read()`` method, 636s such as a file handle (e.g. via builtin ``open`` function) 636s or ``StringIO``. 636s 636s .. deprecated:: 2.1.0 636s Passing json literal strings is deprecated. 636s 636s orient : str, optional 636s Indication of expected JSON string format. 636s Compatible JSON strings can be produced by ``to_json()`` with a 636s corresponding orient value. 636s The set of possible orients is: 636s 636s - ``'split'`` : dict like 636s ``{{index -> [index], columns -> [columns], data -> [values]}}`` 636s - ``'records'`` : list like 636s ``[{{column -> value}}, ... , {{column -> value}}]`` 636s - ``'index'`` : dict like ``{{index -> {{column -> value}}}}`` 636s - ``'columns'`` : dict like ``{{column -> {{index -> value}}}}`` 636s - ``'values'`` : just the values array 636s - ``'table'`` : dict like ``{{'schema': {{schema}}, 'data': {{data}}}}`` 636s 636s The allowed and default values depend on the value 636s of the `typ` parameter. 636s 636s * when ``typ == 'series'``, 636s 636s - allowed orients are ``{{'split','records','index'}}`` 636s - default is ``'index'`` 636s - The Series index must be unique for orient ``'index'``. 636s 636s * when ``typ == 'frame'``, 636s 636s - allowed orients are ``{{'split','records','index', 636s 'columns','values', 'table'}}`` 636s - default is ``'columns'`` 636s - The DataFrame index must be unique for orients ``'index'`` and 636s ``'columns'``. 636s - The DataFrame columns must be unique for orients ``'index'``, 636s ``'columns'``, and ``'records'``. 636s 636s typ : {{'frame', 'series'}}, default 'frame' 636s The type of object to recover. 636s 636s dtype : bool or dict, default None 636s If True, infer dtypes; if a dict of column to dtype, then use those; 636s if False, then don't infer dtypes at all, applies only to the data. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_axes : bool, default None 636s Try to convert the axes to the proper dtypes. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_dates : bool or list of str, default True 636s If True then default datelike columns may be converted (depending on 636s keep_default_dates). 636s If False, no dates will be converted. 636s If a list of column names, then those columns will be converted and 636s default datelike columns may also be converted (depending on 636s keep_default_dates). 636s 636s keep_default_dates : bool, default True 636s If parsing dates (convert_dates is not False), then try to parse the 636s default datelike columns. 636s A column label is datelike if 636s 636s * it ends with ``'_at'``, 636s 636s * it ends with ``'_time'``, 636s 636s * it begins with ``'timestamp'``, 636s 636s * it is ``'modified'``, or 636s 636s * it is ``'date'``. 636s 636s precise_float : bool, default False 636s Set to enable usage of higher precision (strtod) function when 636s decoding string to double values. Default (False) is to use fast but 636s less precise builtin functionality. 636s 636s date_unit : str, default None 636s The timestamp unit to detect if converting dates. The default behaviour 636s is to try and detect the correct precision, but if this is not desired 636s then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds, 636s milliseconds, microseconds or nanoseconds respectively. 636s 636s encoding : str, default is 'utf-8' 636s The encoding to use to decode py3 bytes. 636s 636s encoding_errors : str, optional, default "strict" 636s How encoding errors are treated. `List of possible values 636s `_ . 636s 636s .. versionadded:: 1.3.0 636s 636s lines : bool, default False 636s Read the file as a json object per line. 636s 636s chunksize : int, optional 636s Return JsonReader object for iteration. 636s See the `line-delimited json docs 636s `_ 636s for more information on ``chunksize``. 636s This can only be passed if `lines=True`. 636s If this is None, the file will be read into memory all at once. 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s nrows : int, optional 636s The number of lines from the line-delimited jsonfile that has to be read. 636s This can only be passed if `lines=True`. 636s If this is None, all the rows will be returned. 636s 636s {storage_options} 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s engine : {{"ujson", "pyarrow"}}, default "ujson" 636s Parser engine to use. The ``"pyarrow"`` engine is only available when 636s ``lines=True``. 636s 636s .. versionadded:: 2.0 636s 636s Returns 636s ------- 636s Series, DataFrame, or pandas.api.typing.JsonReader 636s A JsonReader is returned when ``chunksize`` is not ``0`` or ``None``. 636s Otherwise, the type returned depends on the value of ``typ``. 636s 636s See Also 636s -------- 636s DataFrame.to_json : Convert a DataFrame to a JSON string. 636s Series.to_json : Convert a Series to a JSON string. 636s json_normalize : Normalize semi-structured JSON data into a flat table. 636s 636s Notes 636s ----- 636s Specific to ``orient='table'``, if a :class:`DataFrame` with a literal 636s :class:`Index` name of `index` gets written with :func:`to_json`, the 636s subsequent read operation will incorrectly set the :class:`Index` name to 636s ``None``. This is because `index` is also used by :func:`DataFrame.to_json` 636s to denote a missing :class:`Index` name, and the subsequent 636s :func:`read_json` operation cannot distinguish between the two. The same 636s limitation is encountered with a :class:`MultiIndex` and any names 636s beginning with ``'level_'``. 636s 636s Examples 636s -------- 636s >>> from io import StringIO 636s >>> df = pd.DataFrame([['a', 'b'], ['c', 'd']], 636s ... index=['row 1', 'row 2'], 636s ... columns=['col 1', 'col 2']) 636s 636s Encoding/decoding a Dataframe using ``'split'`` formatted JSON: 636s 636s >>> df.to_json(orient='split') 636s '\ 636s {{\ 636s "columns":["col 1","col 2"],\ 636s "index":["row 1","row 2"],\ 636s "data":[["a","b"],["c","d"]]\ 636s }}\ 636s ' 636s >>> pd.read_json(StringIO(_), orient='split') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'index'`` formatted JSON: 636s 636s >>> df.to_json(orient='index') 636s '{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}' 636s 636s >>> pd.read_json(StringIO(_), orient='index') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'records'`` formatted JSON. 636s Note that index labels are not preserved with this encoding. 636s 636s >>> df.to_json(orient='records') 636s '[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]' 636s >>> pd.read_json(StringIO(_), orient='records') 636s col 1 col 2 636s 0 a b 636s 1 c d 636s 636s Encoding with Table Schema 636s 636s >>> df.to_json(orient='table') 636s '\ 636s {{"schema":{{"fields":[\ 636s {{"name":"index","type":"string"}},\ 636s {{"name":"col 1","type":"string"}},\ 636s {{"name":"col 2","type":"string"}}],\ 636s "primaryKey":["index"],\ 636s "pandas_version":"1.4.0"}},\ 636s "data":[\ 636s {{"index":"row 1","col 1":"a","col 2":"b"}},\ 636s {{"index":"row 2","col 1":"c","col 2":"d"}}]\ 636s }}\ 636s ' 636s 636s The following example uses ``dtype_backend="numpy_nullable"`` 636s 636s >>> data = '''{{"index": {{"0": 0, "1": 1}}, 636s ... "a": {{"0": 1, "1": null}}, 636s ... "b": {{"0": 2.5, "1": 4.5}}, 636s ... "c": {{"0": true, "1": false}}, 636s ... "d": {{"0": "a", "1": "b"}}, 636s ... "e": {{"0": 1577.2, "1": 1577.1}}}}''' 636s >>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable") 636s index a b c d e 636s 0 0 1 2.5 True a 1577.2 636s 1 1 4.5 False b 1577.1 636s """ 636s if orient == "table" and dtype: 636s raise ValueError("cannot pass both dtype and orient='table'") 636s if orient == "table" and convert_axes: 636s raise ValueError("cannot pass both convert_axes and orient='table'") 636s 636s check_dtype_backend(dtype_backend) 636s 636s if dtype is None and orient != "table": 636s # error: Incompatible types in assignment (expression has type "bool", variable 636s # has type "Union[ExtensionDtype, str, dtype[Any], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object], Dict[Hashable, 636s # Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object]]], None]") 636s dtype = True # type: ignore[assignment] 636s if convert_axes is None and orient != "table": 636s convert_axes = True 636s 636s > json_reader = JsonReader( 636s path_or_buf, 636s orient=orient, 636s typ=typ, 636s dtype=dtype, 636s convert_axes=convert_axes, 636s convert_dates=convert_dates, 636s keep_default_dates=keep_default_dates, 636s precise_float=precise_float, 636s date_unit=date_unit, 636s encoding=encoding, 636s lines=lines, 636s chunksize=chunksize, 636s compression=compression, 636s nrows=nrows, 636s storage_options=storage_options, 636s encoding_errors=encoding_errors, 636s dtype_backend=dtype_backend, 636s engine=engine, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:791: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:41883', orient = None, typ = 'frame' 636s dtype = True, convert_axes = True, convert_dates = True 636s keep_default_dates = True, precise_float = False, date_unit = None 636s encoding = None, lines = False, chunksize = None, compression = 'infer' 636s nrows = None, storage_options = None, encoding_errors = 'strict' 636s dtype_backend = , engine = 'ujson' 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s orient, 636s typ: FrameSeriesStrT, 636s dtype, 636s convert_axes: bool | None, 636s convert_dates, 636s keep_default_dates: bool, 636s precise_float: bool, 636s date_unit, 636s encoding, 636s lines: bool, 636s chunksize: int | None, 636s compression: CompressionOptions, 636s nrows: int | None, 636s storage_options: StorageOptions | None = None, 636s encoding_errors: str | None = "strict", 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> None: 636s self.orient = orient 636s self.typ = typ 636s self.dtype = dtype 636s self.convert_axes = convert_axes 636s self.convert_dates = convert_dates 636s self.keep_default_dates = keep_default_dates 636s self.precise_float = precise_float 636s self.date_unit = date_unit 636s self.encoding = encoding 636s self.engine = engine 636s self.compression = compression 636s self.storage_options = storage_options 636s self.lines = lines 636s self.chunksize = chunksize 636s self.nrows_seen = 0 636s self.nrows = nrows 636s self.encoding_errors = encoding_errors 636s self.handles: IOHandles[str] | None = None 636s self.dtype_backend = dtype_backend 636s 636s if self.engine not in {"pyarrow", "ujson"}: 636s raise ValueError( 636s f"The engine type {self.engine} is currently not supported." 636s ) 636s if self.chunksize is not None: 636s self.chunksize = validate_integer("chunksize", self.chunksize, 1) 636s if not self.lines: 636s raise ValueError("chunksize can only be passed if lines=True") 636s if self.engine == "pyarrow": 636s raise ValueError( 636s "currently pyarrow engine doesn't support chunksize parameter" 636s ) 636s if self.nrows is not None: 636s self.nrows = validate_integer("nrows", self.nrows, 0) 636s if not self.lines: 636s raise ValueError("nrows can only be passed if lines=True") 636s if ( 636s isinstance(filepath_or_buffer, str) 636s and not self.lines 636s and "\n" in filepath_or_buffer 636s ): 636s warnings.warn( 636s "Passing literal json to 'read_json' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s if self.engine == "pyarrow": 636s if not self.lines: 636s raise ValueError( 636s "currently pyarrow engine only supports " 636s "the line-delimited JSON format" 636s ) 636s self.data = filepath_or_buffer 636s elif self.engine == "ujson": 636s > data = self._get_data_from_filepath(filepath_or_buffer) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:904: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:41883' 636s 636s def _get_data_from_filepath(self, filepath_or_buffer): 636s """ 636s The function read_json accepts three input types: 636s 1. filepath (string-like) 636s 2. file-like object (e.g. open file object, StringIO) 636s 3. JSON string 636s 636s This method turns (1) into (2) to simplify the rest of the processing. 636s It returns input types (2) and (3) unchanged. 636s 636s It raises FileNotFoundError if the input is a string ending in 636s one of .json, .json.gz, .json.bz2, etc. but no such file exists. 636s """ 636s # if it is a string but the file does not exist, it might be a JSON string 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s if ( 636s not isinstance(filepath_or_buffer, str) 636s or is_url(filepath_or_buffer) 636s or is_fsspec_url(filepath_or_buffer) 636s or file_exists(filepath_or_buffer) 636s ): 636s > self.handles = get_handle( 636s filepath_or_buffer, 636s "r", 636s encoding=self.encoding, 636s compression=self.compression, 636s storage_options=self.storage_options, 636s errors=self.encoding_errors, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:944: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:41883', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:41883', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ____________ TestPandasContainer.test_url[closed_at-datetime64[ns]] ____________ 636s 636s self = 636s field = 'closed_at', dtype = 'datetime64[ns]' 636s httpserver = , started 133470494824128)> 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize( 636s "field,dtype", 636s [ 636s ["created_at", pd.DatetimeTZDtype(tz="UTC")], 636s ["closed_at", "datetime64[ns]"], 636s ["updated_at", pd.DatetimeTZDtype(tz="UTC")], 636s ], 636s ) 636s def test_url(self, field, dtype, httpserver): 636s data = '{"created_at": ["2023-06-23T18:21:36Z"], "closed_at": ["2023-06-23T18:21:36"], "updated_at": ["2023-06-23T18:21:36Z"]}\n' # noqa: E501 636s httpserver.serve_content(content=data) 636s > result = read_json(httpserver.url, convert_dates=True) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py:1079: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:46255' 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "path_or_buf", 636s ) 636s def read_json( 636s path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], 636s *, 636s orient: str | None = None, 636s typ: Literal["frame", "series"] = "frame", 636s dtype: DtypeArg | None = None, 636s convert_axes: bool | None = None, 636s convert_dates: bool | list[str] = True, 636s keep_default_dates: bool = True, 636s precise_float: bool = False, 636s date_unit: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s lines: bool = False, 636s chunksize: int | None = None, 636s compression: CompressionOptions = "infer", 636s nrows: int | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> DataFrame | Series | JsonReader: 636s """ 636s Convert a JSON string to pandas object. 636s 636s Parameters 636s ---------- 636s path_or_buf : a valid JSON str, path object or file-like object 636s Any valid string path is acceptable. The string could be a URL. Valid 636s URL schemes include http, ftp, s3, and file. For file URLs, a host is 636s expected. A local file could be: 636s ``file://localhost/path/to/table.json``. 636s 636s If you want to pass in a path object, pandas accepts any 636s ``os.PathLike``. 636s 636s By file-like object, we refer to objects with a ``read()`` method, 636s such as a file handle (e.g. via builtin ``open`` function) 636s or ``StringIO``. 636s 636s .. deprecated:: 2.1.0 636s Passing json literal strings is deprecated. 636s 636s orient : str, optional 636s Indication of expected JSON string format. 636s Compatible JSON strings can be produced by ``to_json()`` with a 636s corresponding orient value. 636s The set of possible orients is: 636s 636s - ``'split'`` : dict like 636s ``{{index -> [index], columns -> [columns], data -> [values]}}`` 636s - ``'records'`` : list like 636s ``[{{column -> value}}, ... , {{column -> value}}]`` 636s - ``'index'`` : dict like ``{{index -> {{column -> value}}}}`` 636s - ``'columns'`` : dict like ``{{column -> {{index -> value}}}}`` 636s - ``'values'`` : just the values array 636s - ``'table'`` : dict like ``{{'schema': {{schema}}, 'data': {{data}}}}`` 636s 636s The allowed and default values depend on the value 636s of the `typ` parameter. 636s 636s * when ``typ == 'series'``, 636s 636s - allowed orients are ``{{'split','records','index'}}`` 636s - default is ``'index'`` 636s - The Series index must be unique for orient ``'index'``. 636s 636s * when ``typ == 'frame'``, 636s 636s - allowed orients are ``{{'split','records','index', 636s 'columns','values', 'table'}}`` 636s - default is ``'columns'`` 636s - The DataFrame index must be unique for orients ``'index'`` and 636s ``'columns'``. 636s - The DataFrame columns must be unique for orients ``'index'``, 636s ``'columns'``, and ``'records'``. 636s 636s typ : {{'frame', 'series'}}, default 'frame' 636s The type of object to recover. 636s 636s dtype : bool or dict, default None 636s If True, infer dtypes; if a dict of column to dtype, then use those; 636s if False, then don't infer dtypes at all, applies only to the data. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_axes : bool, default None 636s Try to convert the axes to the proper dtypes. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_dates : bool or list of str, default True 636s If True then default datelike columns may be converted (depending on 636s keep_default_dates). 636s If False, no dates will be converted. 636s If a list of column names, then those columns will be converted and 636s default datelike columns may also be converted (depending on 636s keep_default_dates). 636s 636s keep_default_dates : bool, default True 636s If parsing dates (convert_dates is not False), then try to parse the 636s default datelike columns. 636s A column label is datelike if 636s 636s * it ends with ``'_at'``, 636s 636s * it ends with ``'_time'``, 636s 636s * it begins with ``'timestamp'``, 636s 636s * it is ``'modified'``, or 636s 636s * it is ``'date'``. 636s 636s precise_float : bool, default False 636s Set to enable usage of higher precision (strtod) function when 636s decoding string to double values. Default (False) is to use fast but 636s less precise builtin functionality. 636s 636s date_unit : str, default None 636s The timestamp unit to detect if converting dates. The default behaviour 636s is to try and detect the correct precision, but if this is not desired 636s then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds, 636s milliseconds, microseconds or nanoseconds respectively. 636s 636s encoding : str, default is 'utf-8' 636s The encoding to use to decode py3 bytes. 636s 636s encoding_errors : str, optional, default "strict" 636s How encoding errors are treated. `List of possible values 636s `_ . 636s 636s .. versionadded:: 1.3.0 636s 636s lines : bool, default False 636s Read the file as a json object per line. 636s 636s chunksize : int, optional 636s Return JsonReader object for iteration. 636s See the `line-delimited json docs 636s `_ 636s for more information on ``chunksize``. 636s This can only be passed if `lines=True`. 636s If this is None, the file will be read into memory all at once. 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s nrows : int, optional 636s The number of lines from the line-delimited jsonfile that has to be read. 636s This can only be passed if `lines=True`. 636s If this is None, all the rows will be returned. 636s 636s {storage_options} 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s engine : {{"ujson", "pyarrow"}}, default "ujson" 636s Parser engine to use. The ``"pyarrow"`` engine is only available when 636s ``lines=True``. 636s 636s .. versionadded:: 2.0 636s 636s Returns 636s ------- 636s Series, DataFrame, or pandas.api.typing.JsonReader 636s A JsonReader is returned when ``chunksize`` is not ``0`` or ``None``. 636s Otherwise, the type returned depends on the value of ``typ``. 636s 636s See Also 636s -------- 636s DataFrame.to_json : Convert a DataFrame to a JSON string. 636s Series.to_json : Convert a Series to a JSON string. 636s json_normalize : Normalize semi-structured JSON data into a flat table. 636s 636s Notes 636s ----- 636s Specific to ``orient='table'``, if a :class:`DataFrame` with a literal 636s :class:`Index` name of `index` gets written with :func:`to_json`, the 636s subsequent read operation will incorrectly set the :class:`Index` name to 636s ``None``. This is because `index` is also used by :func:`DataFrame.to_json` 636s to denote a missing :class:`Index` name, and the subsequent 636s :func:`read_json` operation cannot distinguish between the two. The same 636s limitation is encountered with a :class:`MultiIndex` and any names 636s beginning with ``'level_'``. 636s 636s Examples 636s -------- 636s >>> from io import StringIO 636s >>> df = pd.DataFrame([['a', 'b'], ['c', 'd']], 636s ... index=['row 1', 'row 2'], 636s ... columns=['col 1', 'col 2']) 636s 636s Encoding/decoding a Dataframe using ``'split'`` formatted JSON: 636s 636s >>> df.to_json(orient='split') 636s '\ 636s {{\ 636s "columns":["col 1","col 2"],\ 636s "index":["row 1","row 2"],\ 636s "data":[["a","b"],["c","d"]]\ 636s }}\ 636s ' 636s >>> pd.read_json(StringIO(_), orient='split') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'index'`` formatted JSON: 636s 636s >>> df.to_json(orient='index') 636s '{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}' 636s 636s >>> pd.read_json(StringIO(_), orient='index') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'records'`` formatted JSON. 636s Note that index labels are not preserved with this encoding. 636s 636s >>> df.to_json(orient='records') 636s '[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]' 636s >>> pd.read_json(StringIO(_), orient='records') 636s col 1 col 2 636s 0 a b 636s 1 c d 636s 636s Encoding with Table Schema 636s 636s >>> df.to_json(orient='table') 636s '\ 636s {{"schema":{{"fields":[\ 636s {{"name":"index","type":"string"}},\ 636s {{"name":"col 1","type":"string"}},\ 636s {{"name":"col 2","type":"string"}}],\ 636s "primaryKey":["index"],\ 636s "pandas_version":"1.4.0"}},\ 636s "data":[\ 636s {{"index":"row 1","col 1":"a","col 2":"b"}},\ 636s {{"index":"row 2","col 1":"c","col 2":"d"}}]\ 636s }}\ 636s ' 636s 636s The following example uses ``dtype_backend="numpy_nullable"`` 636s 636s >>> data = '''{{"index": {{"0": 0, "1": 1}}, 636s ... "a": {{"0": 1, "1": null}}, 636s ... "b": {{"0": 2.5, "1": 4.5}}, 636s ... "c": {{"0": true, "1": false}}, 636s ... "d": {{"0": "a", "1": "b"}}, 636s ... "e": {{"0": 1577.2, "1": 1577.1}}}}''' 636s >>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable") 636s index a b c d e 636s 0 0 1 2.5 True a 1577.2 636s 1 1 4.5 False b 1577.1 636s """ 636s if orient == "table" and dtype: 636s raise ValueError("cannot pass both dtype and orient='table'") 636s if orient == "table" and convert_axes: 636s raise ValueError("cannot pass both convert_axes and orient='table'") 636s 636s check_dtype_backend(dtype_backend) 636s 636s if dtype is None and orient != "table": 636s # error: Incompatible types in assignment (expression has type "bool", variable 636s # has type "Union[ExtensionDtype, str, dtype[Any], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object], Dict[Hashable, 636s # Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object]]], None]") 636s dtype = True # type: ignore[assignment] 636s if convert_axes is None and orient != "table": 636s convert_axes = True 636s 636s > json_reader = JsonReader( 636s path_or_buf, 636s orient=orient, 636s typ=typ, 636s dtype=dtype, 636s convert_axes=convert_axes, 636s convert_dates=convert_dates, 636s keep_default_dates=keep_default_dates, 636s precise_float=precise_float, 636s date_unit=date_unit, 636s encoding=encoding, 636s lines=lines, 636s chunksize=chunksize, 636s compression=compression, 636s nrows=nrows, 636s storage_options=storage_options, 636s encoding_errors=encoding_errors, 636s dtype_backend=dtype_backend, 636s engine=engine, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:791: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:46255', orient = None, typ = 'frame' 636s dtype = True, convert_axes = True, convert_dates = True 636s keep_default_dates = True, precise_float = False, date_unit = None 636s encoding = None, lines = False, chunksize = None, compression = 'infer' 636s nrows = None, storage_options = None, encoding_errors = 'strict' 636s dtype_backend = , engine = 'ujson' 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s orient, 636s typ: FrameSeriesStrT, 636s dtype, 636s convert_axes: bool | None, 636s convert_dates, 636s keep_default_dates: bool, 636s precise_float: bool, 636s date_unit, 636s encoding, 636s lines: bool, 636s chunksize: int | None, 636s compression: CompressionOptions, 636s nrows: int | None, 636s storage_options: StorageOptions | None = None, 636s encoding_errors: str | None = "strict", 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> None: 636s self.orient = orient 636s self.typ = typ 636s self.dtype = dtype 636s self.convert_axes = convert_axes 636s self.convert_dates = convert_dates 636s self.keep_default_dates = keep_default_dates 636s self.precise_float = precise_float 636s self.date_unit = date_unit 636s self.encoding = encoding 636s self.engine = engine 636s self.compression = compression 636s self.storage_options = storage_options 636s self.lines = lines 636s self.chunksize = chunksize 636s self.nrows_seen = 0 636s self.nrows = nrows 636s self.encoding_errors = encoding_errors 636s self.handles: IOHandles[str] | None = None 636s self.dtype_backend = dtype_backend 636s 636s if self.engine not in {"pyarrow", "ujson"}: 636s raise ValueError( 636s f"The engine type {self.engine} is currently not supported." 636s ) 636s if self.chunksize is not None: 636s self.chunksize = validate_integer("chunksize", self.chunksize, 1) 636s if not self.lines: 636s raise ValueError("chunksize can only be passed if lines=True") 636s if self.engine == "pyarrow": 636s raise ValueError( 636s "currently pyarrow engine doesn't support chunksize parameter" 636s ) 636s if self.nrows is not None: 636s self.nrows = validate_integer("nrows", self.nrows, 0) 636s if not self.lines: 636s raise ValueError("nrows can only be passed if lines=True") 636s if ( 636s isinstance(filepath_or_buffer, str) 636s and not self.lines 636s and "\n" in filepath_or_buffer 636s ): 636s warnings.warn( 636s "Passing literal json to 'read_json' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s if self.engine == "pyarrow": 636s if not self.lines: 636s raise ValueError( 636s "currently pyarrow engine only supports " 636s "the line-delimited JSON format" 636s ) 636s self.data = filepath_or_buffer 636s elif self.engine == "ujson": 636s > data = self._get_data_from_filepath(filepath_or_buffer) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:904: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:46255' 636s 636s def _get_data_from_filepath(self, filepath_or_buffer): 636s """ 636s The function read_json accepts three input types: 636s 1. filepath (string-like) 636s 2. file-like object (e.g. open file object, StringIO) 636s 3. JSON string 636s 636s This method turns (1) into (2) to simplify the rest of the processing. 636s It returns input types (2) and (3) unchanged. 636s 636s It raises FileNotFoundError if the input is a string ending in 636s one of .json, .json.gz, .json.bz2, etc. but no such file exists. 636s """ 636s # if it is a string but the file does not exist, it might be a JSON string 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s if ( 636s not isinstance(filepath_or_buffer, str) 636s or is_url(filepath_or_buffer) 636s or is_fsspec_url(filepath_or_buffer) 636s or file_exists(filepath_or_buffer) 636s ): 636s > self.handles = get_handle( 636s filepath_or_buffer, 636s "r", 636s encoding=self.encoding, 636s compression=self.compression, 636s storage_options=self.storage_options, 636s errors=self.encoding_errors, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:944: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:46255', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46255', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______________ TestPandasContainer.test_url[updated_at-dtype2] ________________ 636s 636s self = 636s field = 'updated_at', dtype = datetime64[ns, UTC] 636s httpserver = , started 133470403688128)> 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize( 636s "field,dtype", 636s [ 636s ["created_at", pd.DatetimeTZDtype(tz="UTC")], 636s ["closed_at", "datetime64[ns]"], 636s ["updated_at", pd.DatetimeTZDtype(tz="UTC")], 636s ], 636s ) 636s def test_url(self, field, dtype, httpserver): 636s data = '{"created_at": ["2023-06-23T18:21:36Z"], "closed_at": ["2023-06-23T18:21:36"], "updated_at": ["2023-06-23T18:21:36Z"]}\n' # noqa: E501 636s httpserver.serve_content(content=data) 636s > result = read_json(httpserver.url, convert_dates=True) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py:1079: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:44353' 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "path_or_buf", 636s ) 636s def read_json( 636s path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], 636s *, 636s orient: str | None = None, 636s typ: Literal["frame", "series"] = "frame", 636s dtype: DtypeArg | None = None, 636s convert_axes: bool | None = None, 636s convert_dates: bool | list[str] = True, 636s keep_default_dates: bool = True, 636s precise_float: bool = False, 636s date_unit: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s lines: bool = False, 636s chunksize: int | None = None, 636s compression: CompressionOptions = "infer", 636s nrows: int | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> DataFrame | Series | JsonReader: 636s """ 636s Convert a JSON string to pandas object. 636s 636s Parameters 636s ---------- 636s path_or_buf : a valid JSON str, path object or file-like object 636s Any valid string path is acceptable. The string could be a URL. Valid 636s URL schemes include http, ftp, s3, and file. For file URLs, a host is 636s expected. A local file could be: 636s ``file://localhost/path/to/table.json``. 636s 636s If you want to pass in a path object, pandas accepts any 636s ``os.PathLike``. 636s 636s By file-like object, we refer to objects with a ``read()`` method, 636s such as a file handle (e.g. via builtin ``open`` function) 636s or ``StringIO``. 636s 636s .. deprecated:: 2.1.0 636s Passing json literal strings is deprecated. 636s 636s orient : str, optional 636s Indication of expected JSON string format. 636s Compatible JSON strings can be produced by ``to_json()`` with a 636s corresponding orient value. 636s The set of possible orients is: 636s 636s - ``'split'`` : dict like 636s ``{{index -> [index], columns -> [columns], data -> [values]}}`` 636s - ``'records'`` : list like 636s ``[{{column -> value}}, ... , {{column -> value}}]`` 636s - ``'index'`` : dict like ``{{index -> {{column -> value}}}}`` 636s - ``'columns'`` : dict like ``{{column -> {{index -> value}}}}`` 636s - ``'values'`` : just the values array 636s - ``'table'`` : dict like ``{{'schema': {{schema}}, 'data': {{data}}}}`` 636s 636s The allowed and default values depend on the value 636s of the `typ` parameter. 636s 636s * when ``typ == 'series'``, 636s 636s - allowed orients are ``{{'split','records','index'}}`` 636s - default is ``'index'`` 636s - The Series index must be unique for orient ``'index'``. 636s 636s * when ``typ == 'frame'``, 636s 636s - allowed orients are ``{{'split','records','index', 636s 'columns','values', 'table'}}`` 636s - default is ``'columns'`` 636s - The DataFrame index must be unique for orients ``'index'`` and 636s ``'columns'``. 636s - The DataFrame columns must be unique for orients ``'index'``, 636s ``'columns'``, and ``'records'``. 636s 636s typ : {{'frame', 'series'}}, default 'frame' 636s The type of object to recover. 636s 636s dtype : bool or dict, default None 636s If True, infer dtypes; if a dict of column to dtype, then use those; 636s if False, then don't infer dtypes at all, applies only to the data. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_axes : bool, default None 636s Try to convert the axes to the proper dtypes. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_dates : bool or list of str, default True 636s If True then default datelike columns may be converted (depending on 636s keep_default_dates). 636s If False, no dates will be converted. 636s If a list of column names, then those columns will be converted and 636s default datelike columns may also be converted (depending on 636s keep_default_dates). 636s 636s keep_default_dates : bool, default True 636s If parsing dates (convert_dates is not False), then try to parse the 636s default datelike columns. 636s A column label is datelike if 636s 636s * it ends with ``'_at'``, 636s 636s * it ends with ``'_time'``, 636s 636s * it begins with ``'timestamp'``, 636s 636s * it is ``'modified'``, or 636s 636s * it is ``'date'``. 636s 636s precise_float : bool, default False 636s Set to enable usage of higher precision (strtod) function when 636s decoding string to double values. Default (False) is to use fast but 636s less precise builtin functionality. 636s 636s date_unit : str, default None 636s The timestamp unit to detect if converting dates. The default behaviour 636s is to try and detect the correct precision, but if this is not desired 636s then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds, 636s milliseconds, microseconds or nanoseconds respectively. 636s 636s encoding : str, default is 'utf-8' 636s The encoding to use to decode py3 bytes. 636s 636s encoding_errors : str, optional, default "strict" 636s How encoding errors are treated. `List of possible values 636s `_ . 636s 636s .. versionadded:: 1.3.0 636s 636s lines : bool, default False 636s Read the file as a json object per line. 636s 636s chunksize : int, optional 636s Return JsonReader object for iteration. 636s See the `line-delimited json docs 636s `_ 636s for more information on ``chunksize``. 636s This can only be passed if `lines=True`. 636s If this is None, the file will be read into memory all at once. 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s nrows : int, optional 636s The number of lines from the line-delimited jsonfile that has to be read. 636s This can only be passed if `lines=True`. 636s If this is None, all the rows will be returned. 636s 636s {storage_options} 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s engine : {{"ujson", "pyarrow"}}, default "ujson" 636s Parser engine to use. The ``"pyarrow"`` engine is only available when 636s ``lines=True``. 636s 636s .. versionadded:: 2.0 636s 636s Returns 636s ------- 636s Series, DataFrame, or pandas.api.typing.JsonReader 636s A JsonReader is returned when ``chunksize`` is not ``0`` or ``None``. 636s Otherwise, the type returned depends on the value of ``typ``. 636s 636s See Also 636s -------- 636s DataFrame.to_json : Convert a DataFrame to a JSON string. 636s Series.to_json : Convert a Series to a JSON string. 636s json_normalize : Normalize semi-structured JSON data into a flat table. 636s 636s Notes 636s ----- 636s Specific to ``orient='table'``, if a :class:`DataFrame` with a literal 636s :class:`Index` name of `index` gets written with :func:`to_json`, the 636s subsequent read operation will incorrectly set the :class:`Index` name to 636s ``None``. This is because `index` is also used by :func:`DataFrame.to_json` 636s to denote a missing :class:`Index` name, and the subsequent 636s :func:`read_json` operation cannot distinguish between the two. The same 636s limitation is encountered with a :class:`MultiIndex` and any names 636s beginning with ``'level_'``. 636s 636s Examples 636s -------- 636s >>> from io import StringIO 636s >>> df = pd.DataFrame([['a', 'b'], ['c', 'd']], 636s ... index=['row 1', 'row 2'], 636s ... columns=['col 1', 'col 2']) 636s 636s Encoding/decoding a Dataframe using ``'split'`` formatted JSON: 636s 636s >>> df.to_json(orient='split') 636s '\ 636s {{\ 636s "columns":["col 1","col 2"],\ 636s "index":["row 1","row 2"],\ 636s "data":[["a","b"],["c","d"]]\ 636s }}\ 636s ' 636s >>> pd.read_json(StringIO(_), orient='split') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'index'`` formatted JSON: 636s 636s >>> df.to_json(orient='index') 636s '{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}' 636s 636s >>> pd.read_json(StringIO(_), orient='index') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'records'`` formatted JSON. 636s Note that index labels are not preserved with this encoding. 636s 636s >>> df.to_json(orient='records') 636s '[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]' 636s >>> pd.read_json(StringIO(_), orient='records') 636s col 1 col 2 636s 0 a b 636s 1 c d 636s 636s Encoding with Table Schema 636s 636s >>> df.to_json(orient='table') 636s '\ 636s {{"schema":{{"fields":[\ 636s {{"name":"index","type":"string"}},\ 636s {{"name":"col 1","type":"string"}},\ 636s {{"name":"col 2","type":"string"}}],\ 636s "primaryKey":["index"],\ 636s "pandas_version":"1.4.0"}},\ 636s "data":[\ 636s {{"index":"row 1","col 1":"a","col 2":"b"}},\ 636s {{"index":"row 2","col 1":"c","col 2":"d"}}]\ 636s }}\ 636s ' 636s 636s The following example uses ``dtype_backend="numpy_nullable"`` 636s 636s >>> data = '''{{"index": {{"0": 0, "1": 1}}, 636s ... "a": {{"0": 1, "1": null}}, 636s ... "b": {{"0": 2.5, "1": 4.5}}, 636s ... "c": {{"0": true, "1": false}}, 636s ... "d": {{"0": "a", "1": "b"}}, 636s ... "e": {{"0": 1577.2, "1": 1577.1}}}}''' 636s >>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable") 636s index a b c d e 636s 0 0 1 2.5 True a 1577.2 636s 1 1 4.5 False b 1577.1 636s """ 636s if orient == "table" and dtype: 636s raise ValueError("cannot pass both dtype and orient='table'") 636s if orient == "table" and convert_axes: 636s raise ValueError("cannot pass both convert_axes and orient='table'") 636s 636s check_dtype_backend(dtype_backend) 636s 636s if dtype is None and orient != "table": 636s # error: Incompatible types in assignment (expression has type "bool", variable 636s # has type "Union[ExtensionDtype, str, dtype[Any], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object], Dict[Hashable, 636s # Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object]]], None]") 636s dtype = True # type: ignore[assignment] 636s if convert_axes is None and orient != "table": 636s convert_axes = True 636s 636s > json_reader = JsonReader( 636s path_or_buf, 636s orient=orient, 636s typ=typ, 636s dtype=dtype, 636s convert_axes=convert_axes, 636s convert_dates=convert_dates, 636s keep_default_dates=keep_default_dates, 636s precise_float=precise_float, 636s date_unit=date_unit, 636s encoding=encoding, 636s lines=lines, 636s chunksize=chunksize, 636s compression=compression, 636s nrows=nrows, 636s storage_options=storage_options, 636s encoding_errors=encoding_errors, 636s dtype_backend=dtype_backend, 636s engine=engine, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:791: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:44353', orient = None, typ = 'frame' 636s dtype = True, convert_axes = True, convert_dates = True 636s keep_default_dates = True, precise_float = False, date_unit = None 636s encoding = None, lines = False, chunksize = None, compression = 'infer' 636s nrows = None, storage_options = None, encoding_errors = 'strict' 636s dtype_backend = , engine = 'ujson' 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s orient, 636s typ: FrameSeriesStrT, 636s dtype, 636s convert_axes: bool | None, 636s convert_dates, 636s keep_default_dates: bool, 636s precise_float: bool, 636s date_unit, 636s encoding, 636s lines: bool, 636s chunksize: int | None, 636s compression: CompressionOptions, 636s nrows: int | None, 636s storage_options: StorageOptions | None = None, 636s encoding_errors: str | None = "strict", 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> None: 636s self.orient = orient 636s self.typ = typ 636s self.dtype = dtype 636s self.convert_axes = convert_axes 636s self.convert_dates = convert_dates 636s self.keep_default_dates = keep_default_dates 636s self.precise_float = precise_float 636s self.date_unit = date_unit 636s self.encoding = encoding 636s self.engine = engine 636s self.compression = compression 636s self.storage_options = storage_options 636s self.lines = lines 636s self.chunksize = chunksize 636s self.nrows_seen = 0 636s self.nrows = nrows 636s self.encoding_errors = encoding_errors 636s self.handles: IOHandles[str] | None = None 636s self.dtype_backend = dtype_backend 636s 636s if self.engine not in {"pyarrow", "ujson"}: 636s raise ValueError( 636s f"The engine type {self.engine} is currently not supported." 636s ) 636s if self.chunksize is not None: 636s self.chunksize = validate_integer("chunksize", self.chunksize, 1) 636s if not self.lines: 636s raise ValueError("chunksize can only be passed if lines=True") 636s if self.engine == "pyarrow": 636s raise ValueError( 636s "currently pyarrow engine doesn't support chunksize parameter" 636s ) 636s if self.nrows is not None: 636s self.nrows = validate_integer("nrows", self.nrows, 0) 636s if not self.lines: 636s raise ValueError("nrows can only be passed if lines=True") 636s if ( 636s isinstance(filepath_or_buffer, str) 636s and not self.lines 636s and "\n" in filepath_or_buffer 636s ): 636s warnings.warn( 636s "Passing literal json to 'read_json' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s if self.engine == "pyarrow": 636s if not self.lines: 636s raise ValueError( 636s "currently pyarrow engine only supports " 636s "the line-delimited JSON format" 636s ) 636s self.data = filepath_or_buffer 636s elif self.engine == "ujson": 636s > data = self._get_data_from_filepath(filepath_or_buffer) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:904: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:44353' 636s 636s def _get_data_from_filepath(self, filepath_or_buffer): 636s """ 636s The function read_json accepts three input types: 636s 1. filepath (string-like) 636s 2. file-like object (e.g. open file object, StringIO) 636s 3. JSON string 636s 636s This method turns (1) into (2) to simplify the rest of the processing. 636s It returns input types (2) and (3) unchanged. 636s 636s It raises FileNotFoundError if the input is a string ending in 636s one of .json, .json.gz, .json.bz2, etc. but no such file exists. 636s """ 636s # if it is a string but the file does not exist, it might be a JSON string 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s if ( 636s not isinstance(filepath_or_buffer, str) 636s or is_url(filepath_or_buffer) 636s or is_fsspec_url(filepath_or_buffer) 636s or file_exists(filepath_or_buffer) 636s ): 636s > self.handles = get_handle( 636s filepath_or_buffer, 636s "r", 636s encoding=self.encoding, 636s compression=self.compression, 636s storage_options=self.storage_options, 636s errors=self.encoding_errors, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:944: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:44353', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44353', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______________________________ test_url[c_high] _______________________________ 636s 636s all_parsers = 636s csv_dir_path = '/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests/io/parser/data' 636s httpserver = , started 133470403688128)> 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_url(all_parsers, csv_dir_path, httpserver): 636s parser = all_parsers 636s kwargs = {"sep": "\t"} 636s 636s local_path = os.path.join(csv_dir_path, "salaries.csv") 636s with open(local_path, encoding="utf-8") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s > url_result = parser.read_csv(httpserver.url, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_file_buffer_url.py:47: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s args = ('http://127.0.0.1:33369',) 636s kwargs = {'engine': 'c', 'low_memory': False, 'sep': '\t'} 636s 636s def read_csv(self, *args, **kwargs): 636s kwargs = self.update_kwargs(kwargs) 636s > return read_csv(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/conftest.py:31: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:33369' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:33369' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:33369', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:33369', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:33369', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:33369', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______________________________ test_url[c_low] ________________________________ 636s 636s all_parsers = 636s csv_dir_path = '/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests/io/parser/data' 636s httpserver = , started 133470395295424)> 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_url(all_parsers, csv_dir_path, httpserver): 636s parser = all_parsers 636s kwargs = {"sep": "\t"} 636s 636s local_path = os.path.join(csv_dir_path, "salaries.csv") 636s with open(local_path, encoding="utf-8") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s > url_result = parser.read_csv(httpserver.url, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_file_buffer_url.py:47: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s args = ('http://127.0.0.1:39959',) 636s kwargs = {'engine': 'c', 'low_memory': True, 'sep': '\t'} 636s 636s def read_csv(self, *args, **kwargs): 636s kwargs = self.update_kwargs(kwargs) 636s > return read_csv(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/conftest.py:31: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39959' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39959' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:39959', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:39959', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:39959', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39959', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______________________________ test_url[python] _______________________________ 636s 636s all_parsers = 636s csv_dir_path = '/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests/io/parser/data' 636s httpserver = , started 133470486431424)> 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_url(all_parsers, csv_dir_path, httpserver): 636s parser = all_parsers 636s kwargs = {"sep": "\t"} 636s 636s local_path = os.path.join(csv_dir_path, "salaries.csv") 636s with open(local_path, encoding="utf-8") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s > url_result = parser.read_csv(httpserver.url, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_file_buffer_url.py:47: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s args = ('http://127.0.0.1:39835',) 636s kwargs = {'engine': 'python', 'low_memory': True, 'sep': '\t'} 636s 636s def read_csv(self, *args, **kwargs): 636s kwargs = self.update_kwargs(kwargs) 636s > return read_csv(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/conftest.py:31: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39835' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39835' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:39835', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:39835', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:39835', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39835', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s __________________ test_compressed_urls[gzip-python-explicit] __________________ 636s 636s httpserver = , started 133470403688128)> 636s datapath = .deco at 0x7963e0a398a0> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'explicit', engine = 'python', compression_only = 'gzip' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44131/salaries.csv.gz' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44131/salaries.csv.gz' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'gzip', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:44131/salaries.csv.gz', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'gzip', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'gzip', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:44131/salaries.csv.gz', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:44131/salaries.csv.gz', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44131/salaries.csv.gz' 636s encoding = 'utf-8', compression = {'method': 'gzip'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ___________________ test_compressed_urls[gzip-python-infer] ____________________ 636s 636s httpserver = , started 133470494824128)> 636s datapath = .deco at 0x7963e0a0e020> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'infer', engine = 'python', compression_only = 'infer' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43889/salaries.csv.gz' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43889/salaries.csv.gz' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:43889/salaries.csv.gz', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:43889/salaries.csv.gz', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:43889/salaries.csv.gz', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43889/salaries.csv.gz' 636s encoding = 'utf-8', compression = {'method': 'gzip'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ____________________ test_compressed_urls[gzip-c-explicit] _____________________ 636s 636s httpserver = , started 133470486431424)> 636s datapath = .deco at 0x7963e0bb4180> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'explicit', engine = 'c', compression_only = 'gzip' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46089/salaries.csv.gz' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46089/salaries.csv.gz' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'gzip', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:46089/salaries.csv.gz', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'gzip', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'gzip', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:46089/salaries.csv.gz', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:46089/salaries.csv.gz', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46089/salaries.csv.gz' 636s encoding = 'utf-8', compression = {'method': 'gzip'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______________________ test_compressed_urls[gzip-c-infer] ______________________ 636s 636s httpserver = , started 133470395295424)> 636s datapath = .deco at 0x7963e0a39bc0> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'infer', engine = 'c', compression_only = 'infer' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:42529/salaries.csv.gz' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:42529/salaries.csv.gz' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:42529/salaries.csv.gz', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:42529/salaries.csv.gz', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:42529/salaries.csv.gz', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:42529/salaries.csv.gz' 636s encoding = 'utf-8', compression = {'method': 'gzip'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s __________________ test_compressed_urls[bz2-python-explicit] ___________________ 636s 636s httpserver = , started 133470486431424)> 636s datapath = .deco at 0x7963e0bb5d00> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'explicit', engine = 'python', compression_only = 'bz2' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:34037/salaries.csv.bz2' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:34037/salaries.csv.bz2' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'bz2', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:34037/salaries.csv.bz2', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'bz2', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'bz2', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:34037/salaries.csv.bz2', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:34037/salaries.csv.bz2', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:34037/salaries.csv.bz2' 636s encoding = 'utf-8', compression = {'method': 'bz2'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ____________________ test_compressed_urls[bz2-python-infer] ____________________ 636s 636s httpserver = , started 133470494824128)> 636s datapath = .deco at 0x7963e0a3a3e0> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'infer', engine = 'python', compression_only = 'infer' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44493/salaries.csv.bz2' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44493/salaries.csv.bz2' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:44493/salaries.csv.bz2', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:44493/salaries.csv.bz2', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:44493/salaries.csv.bz2', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44493/salaries.csv.bz2' 636s encoding = 'utf-8', compression = {'method': 'bz2'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________________ test_compressed_urls[bz2-c-explicit] _____________________ 636s 636s httpserver = , started 133469864560320)> 636s datapath = .deco at 0x7963e0a3a980> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'explicit', engine = 'c', compression_only = 'bz2' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45159/salaries.csv.bz2' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45159/salaries.csv.bz2' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'bz2', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:45159/salaries.csv.bz2', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'bz2', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'bz2', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:45159/salaries.csv.bz2', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:45159/salaries.csv.bz2', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45159/salaries.csv.bz2' 636s encoding = 'utf-8', compression = {'method': 'bz2'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______________________ test_compressed_urls[bz2-c-infer] _______________________ 636s 636s httpserver = , started 133470494824128)> 636s datapath = .deco at 0x7963e0a3a700> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'infer', engine = 'c', compression_only = 'infer' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:33833/salaries.csv.bz2' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:33833/salaries.csv.bz2' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:33833/salaries.csv.bz2', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:33833/salaries.csv.bz2', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:33833/salaries.csv.bz2', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:33833/salaries.csv.bz2' 636s encoding = 'utf-8', compression = {'method': 'bz2'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s __________________ test_compressed_urls[zip-python-explicit] ___________________ 636s 636s httpserver = , started 133470486431424)> 636s datapath = .deco at 0x7963e0a3ae80> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'explicit', engine = 'python', compression_only = 'zip' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46439/salaries.csv.zip' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46439/salaries.csv.zip' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'zip', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:46439/salaries.csv.zip', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'zip', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'zip', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:46439/salaries.csv.zip', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:46439/salaries.csv.zip', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46439/salaries.csv.zip' 636s encoding = 'utf-8', compression = {'method': 'zip'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ____________________ test_compressed_urls[zip-python-infer] ____________________ 636s 636s httpserver = , started 133469856167616)> 636s datapath = .deco at 0x7963e0a3b420> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'infer', engine = 'python', compression_only = 'infer' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38827/salaries.csv.zip' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38827/salaries.csv.zip' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:38827/salaries.csv.zip', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:38827/salaries.csv.zip', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:38827/salaries.csv.zip', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38827/salaries.csv.zip' 636s encoding = 'utf-8', compression = {'method': 'zip'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________________ test_compressed_urls[zip-c-explicit] _____________________ 636s 636s httpserver = , started 133470486431424)> 636s datapath = .deco at 0x7963e0a3b380> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'explicit', engine = 'c', compression_only = 'zip' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:36051/salaries.csv.zip' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:36051/salaries.csv.zip' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'zip', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:36051/salaries.csv.zip', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'zip', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'zip', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:36051/salaries.csv.zip', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:36051/salaries.csv.zip', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:36051/salaries.csv.zip' 636s encoding = 'utf-8', compression = {'method': 'zip'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______________________ test_compressed_urls[zip-c-infer] _______________________ 636s 636s httpserver = , started 133470494824128)> 636s datapath = .deco at 0x7963e0a3b920> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'infer', engine = 'c', compression_only = 'infer' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:35255/salaries.csv.zip' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:35255/salaries.csv.zip' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:35255/salaries.csv.zip', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:35255/salaries.csv.zip', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:35255/salaries.csv.zip', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:35255/salaries.csv.zip' 636s encoding = 'utf-8', compression = {'method': 'zip'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ___________________ test_compressed_urls[xz-python-explicit] ___________________ 636s 636s httpserver = , started 133469846726336)> 636s datapath = .deco at 0x7963e0a3bec0> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'explicit', engine = 'python', compression_only = 'xz' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45969/salaries.csv.xz' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45969/salaries.csv.xz' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'xz', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:45969/salaries.csv.xz', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'xz', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'xz', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:45969/salaries.csv.xz', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:45969/salaries.csv.xz', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45969/salaries.csv.xz' 636s encoding = 'utf-8', compression = {'method': 'xz'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ____________________ test_compressed_urls[xz-python-infer] _____________________ 636s 636s httpserver = , started 133470494824128)> 636s datapath = .deco at 0x7963e0a3b740> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'infer', engine = 'python', compression_only = 'infer' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38475/salaries.csv.xz' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38475/salaries.csv.xz' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:38475/salaries.csv.xz', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:38475/salaries.csv.xz', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:38475/salaries.csv.xz', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38475/salaries.csv.xz' 636s encoding = 'utf-8', compression = {'method': 'xz'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________________ test_compressed_urls[xz-c-explicit] ______________________ 636s 636s httpserver = , started 133470486431424)> 636s datapath = .deco at 0x7963e0a3b380> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'explicit', engine = 'c', compression_only = 'xz' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43613/salaries.csv.xz' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43613/salaries.csv.xz' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'xz', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:43613/salaries.csv.xz', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'xz', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'xz', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:43613/salaries.csv.xz', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:43613/salaries.csv.xz', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43613/salaries.csv.xz' 636s encoding = 'utf-8', compression = {'method': 'xz'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______________________ test_compressed_urls[xz-c-infer] _______________________ 636s 636s httpserver = , started 133469838333632)> 636s datapath = .deco at 0x7963e09049a0> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'infer', engine = 'c', compression_only = 'infer' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46175/salaries.csv.xz' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46175/salaries.csv.xz' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:46175/salaries.csv.xz', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:46175/salaries.csv.xz', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:46175/salaries.csv.xz', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46175/salaries.csv.xz' 636s encoding = 'utf-8', compression = {'method': 'xz'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s __________________ test_compressed_urls[zstd-python-explicit] __________________ 636s 636s httpserver = , started 133469813155520)> 636s datapath = .deco at 0x7963e0905580> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'explicit', engine = 'python', compression_only = 'zstd' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:41573/salaries.csv.zst' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:41573/salaries.csv.zst' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'zstd', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:41573/salaries.csv.zst', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'zstd', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'zstd', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:41573/salaries.csv.zst', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:41573/salaries.csv.zst', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:41573/salaries.csv.zst' 636s encoding = 'utf-8', compression = {'method': 'zstd'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ___________________ test_compressed_urls[zstd-python-infer] ____________________ 636s 636s httpserver = , started 133469821548224)> 636s datapath = .deco at 0x7963e0904a40> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'infer', engine = 'python', compression_only = 'infer' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:34401/salaries.csv.zst' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:34401/salaries.csv.zst' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:34401/salaries.csv.zst', engine = 'python' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:34401/salaries.csv.zst', engine = 'python' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:34401/salaries.csv.zst', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:34401/salaries.csv.zst' 636s encoding = 'utf-8', compression = {'method': 'zstd'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ____________________ test_compressed_urls[zstd-c-explicit] _____________________ 636s 636s httpserver = , started 133469829940928)> 636s datapath = .deco at 0x7963e0905bc0> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'explicit', engine = 'c', compression_only = 'zstd' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44315/salaries.csv.zst' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44315/salaries.csv.zst' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'zstd', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:44315/salaries.csv.zst', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'zstd', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'zstd', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:44315/salaries.csv.zst', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:44315/salaries.csv.zst', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44315/salaries.csv.zst' 636s encoding = 'utf-8', compression = {'method': 'zstd'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______________________ test_compressed_urls[zstd-c-infer] ______________________ 636s 636s httpserver = , started 133469821548224)> 636s datapath = .deco at 0x7963e0905b20> 636s salaries_table = S X E M 636s 0 13876 1 1 1 636s 1 11608 1 3 0 636s 2 18701 1 3 1 636s 3 11283 1 2 0 636s 4 11767 1 3 ...40 25685 15 3 1 636s 41 27837 16 2 1 636s 42 18838 16 2 0 636s 43 17483 16 1 0 636s 44 19207 17 2 0 636s 45 19346 20 1 0 636s mode = 'infer', engine = 'c', compression_only = 'infer' 636s compression_to_extension = {'bz2': '.bz2', 'gzip': '.gz', 'tar': '.tar.xz', 'xz': '.xz', ...} 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s @pytest.mark.parametrize("mode", ["explicit", "infer"]) 636s @pytest.mark.parametrize("engine", ["python", "c"]) 636s def test_compressed_urls( 636s httpserver, 636s datapath, 636s salaries_table, 636s mode, 636s engine, 636s compression_only, 636s compression_to_extension, 636s ): 636s # test reading compressed urls with various engines and 636s # extension inference 636s if compression_only == "tar": 636s pytest.skip("TODO: Add tar salaraies.csv to pandas/io/parsers/data") 636s 636s extension = compression_to_extension[compression_only] 636s with open(datapath("io", "parser", "data", "salaries.csv" + extension), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s 636s url = httpserver.url + "/salaries.csv" + extension 636s 636s if mode != "explicit": 636s compression_only = mode 636s 636s > url_table = read_csv(url, sep="\t", compression=compression_only, engine=engine) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:52: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38361/salaries.csv.zst' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38361/salaries.csv.zst' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:38361/salaries.csv.zst', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:38361/salaries.csv.zst', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:38361/salaries.csv.zst', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38361/salaries.csv.zst' 636s encoding = 'utf-8', compression = {'method': 'zstd'}, mode = 'r' 636s storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ____________________________ test_url_encoding_csv _____________________________ 636s 636s httpserver = , started 133469813155520)> 636s datapath = .deco at 0x7963e09060c0> 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_url_encoding_csv(httpserver, datapath): 636s """ 636s read_csv should honor the requested encoding for URLs. 636s 636s GH 10424 636s """ 636s with open(datapath("io", "parser", "data", "unicode_series.csv"), "rb") as f: 636s httpserver.serve_content(content=f.read()) 636s > df = read_csv(httpserver.url, encoding="latin-1", header=None) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py:66: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44823' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44823' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:44823', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:44823', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:44823', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:44823', encoding = 'latin-1' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______________________________ test_url_urlopen _______________________________ 636s 636s httpserver = , started 133469813155520)> 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_url_urlopen(httpserver): 636s data = """\ 636s A B C D 636s 201158 360.242940 149.910199 11950.7 636s 201159 444.953632 166.985655 11788.4 636s 201160 364.136849 183.628767 11806.2 636s 201161 413.836124 184.375703 11916.8 636s 201162 502.953953 173.237159 12468.3 636s """ 636s httpserver.serve_content(content=data) 636s expected = pd.Index(list("ABCD")) 636s > with urlopen(httpserver.url) as f: 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/parser/test_read_fwf.py:1042: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = ('http://127.0.0.1:35573',), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = 'http://127.0.0.1:35573', data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = 'http://127.0.0.1:35573', data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________________ TestReadHtml.test_banklist_url[bs4] ______________________ 636s 636s self = 636s httpserver = , started 133469829940928)> 636s banklist_data = '/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests/io/data/html/banklist.html' 636s flavor_read_html = functools.partial(, flavor='bs4') 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_banklist_url(self, httpserver, banklist_data, flavor_read_html): 636s with open(banklist_data, encoding="utf-8") as f: 636s httpserver.serve_content(content=f.read()) 636s > df1 = flavor_read_html( 636s # lxml cannot find attrs leave out for now 636s httpserver.url, 636s match="First Federal Bank of Florida", # attrs={"class": "dataTable"} 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_html.py:233: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:41585' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('bs4',), io = 'http://127.0.0.1:41585' 636s match = 'First Federal Bank of Florida', attrs = None, encoding = None 636s displayed_only = True, extract_links = None, storage_options = None 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('First Federal Bank of Florida'), retained = None 636s flav = 'bs4' 636s parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s from bs4 import BeautifulSoup 636s 636s > bdoc = self._setup_build_doc() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:653: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _setup_build_doc(self): 636s > raw_text = _read(self.io, self.encoding, self.storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:645: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s obj = 'http://127.0.0.1:41585', encoding = None, storage_options = None 636s 636s def _read( 636s obj: FilePath | BaseBuffer, 636s encoding: str | None, 636s storage_options: StorageOptions | None, 636s ) -> str | bytes: 636s """ 636s Try to read from a url, file or string. 636s 636s Parameters 636s ---------- 636s obj : str, unicode, path object, or file-like object 636s 636s Returns 636s ------- 636s raw_text : str 636s """ 636s text: str | bytes 636s if ( 636s is_url(obj) 636s or hasattr(obj, "read") 636s or (isinstance(obj, str) and file_exists(obj)) 636s ): 636s > with get_handle( 636s obj, "r", encoding=encoding, storage_options=storage_options 636s ) as handles: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:143: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:41585', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:41585', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________________ TestReadHtml.test_banklist_url[lxml] _____________________ 636s 636s self = 636s httpserver = , started 133469838333632)> 636s banklist_data = '/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests/io/data/html/banklist.html' 636s flavor_read_html = functools.partial(, flavor='lxml') 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_banklist_url(self, httpserver, banklist_data, flavor_read_html): 636s with open(banklist_data, encoding="utf-8") as f: 636s httpserver.serve_content(content=f.read()) 636s > df1 = flavor_read_html( 636s # lxml cannot find attrs leave out for now 636s httpserver.url, 636s match="First Federal Bank of Florida", # attrs={"class": "dataTable"} 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_html.py:233: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:37887' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('lxml',), io = 'http://127.0.0.1:37887' 636s match = 'First Federal Bank of Florida', attrs = None, encoding = None 636s displayed_only = True, extract_links = None, storage_options = None 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('First Federal Bank of Florida'), retained = None 636s flav = 'lxml', parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s r = parse(f.handle, parser=parser) 636s else: 636s # try to parse the input in the simplest way 636s r = parse(self.io, parser=parser) 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s except (UnicodeDecodeError, OSError) as e: 636s # if the input is a blob of html goop 636s if not is_url(self.io): 636s r = fromstring(self.io, parser=parser) 636s 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s else: 636s > raise e 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:806: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s > with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:785: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:37887', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:37887', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______________________ TestReadHtml.test_spam_url[bs4] ________________________ 636s 636s self = 636s httpserver = , started 133469846726336)> 636s spam_data = '/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests/io/data/html/spam.html' 636s flavor_read_html = functools.partial(, flavor='bs4') 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_spam_url(self, httpserver, spam_data, flavor_read_html): 636s with open(spam_data, encoding="utf-8") as f: 636s httpserver.serve_content(content=f.read()) 636s > df1 = flavor_read_html(httpserver.url, match=".*Water.*") 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_html.py:251: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:38949' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('bs4',), io = 'http://127.0.0.1:38949', match = '.*Water.*' 636s attrs = None, encoding = None, displayed_only = True, extract_links = None 636s storage_options = None 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('.*Water.*'), retained = None, flav = 'bs4' 636s parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s from bs4 import BeautifulSoup 636s 636s > bdoc = self._setup_build_doc() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:653: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _setup_build_doc(self): 636s > raw_text = _read(self.io, self.encoding, self.storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:645: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s obj = 'http://127.0.0.1:38949', encoding = None, storage_options = None 636s 636s def _read( 636s obj: FilePath | BaseBuffer, 636s encoding: str | None, 636s storage_options: StorageOptions | None, 636s ) -> str | bytes: 636s """ 636s Try to read from a url, file or string. 636s 636s Parameters 636s ---------- 636s obj : str, unicode, path object, or file-like object 636s 636s Returns 636s ------- 636s raw_text : str 636s """ 636s text: str | bytes 636s if ( 636s is_url(obj) 636s or hasattr(obj, "read") 636s or (isinstance(obj, str) and file_exists(obj)) 636s ): 636s > with get_handle( 636s obj, "r", encoding=encoding, storage_options=storage_options 636s ) as handles: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:143: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:38949', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38949', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______________________ TestReadHtml.test_spam_url[lxml] _______________________ 636s 636s self = 636s httpserver = , started 133469838333632)> 636s spam_data = '/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests/io/data/html/spam.html' 636s flavor_read_html = functools.partial(, flavor='lxml') 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_spam_url(self, httpserver, spam_data, flavor_read_html): 636s with open(spam_data, encoding="utf-8") as f: 636s httpserver.serve_content(content=f.read()) 636s > df1 = flavor_read_html(httpserver.url, match=".*Water.*") 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_html.py:251: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:32905' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('lxml',), io = 'http://127.0.0.1:32905', match = '.*Water.*' 636s attrs = None, encoding = None, displayed_only = True, extract_links = None 636s storage_options = None 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('.*Water.*'), retained = None, flav = 'lxml' 636s parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s r = parse(f.handle, parser=parser) 636s else: 636s # try to parse the input in the simplest way 636s r = parse(self.io, parser=parser) 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s except (UnicodeDecodeError, OSError) as e: 636s # if the input is a blob of html goop 636s if not is_url(self.io): 636s r = fromstring(self.io, parser=parser) 636s 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s else: 636s > raise e 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:806: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s > with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:785: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:32905', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:32905', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ___________________ TestReadHtml.test_multiple_matches[bs4] ____________________ 636s 636s self = 636s python_docs = '\n \n \n
\n

lists all sections and subsections

\n
\n ' 636s httpserver = , started 133469864560320)> 636s flavor_read_html = functools.partial(, flavor='bs4') 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_multiple_matches(self, python_docs, httpserver, flavor_read_html): 636s httpserver.serve_content(content=python_docs) 636s > dfs = flavor_read_html(httpserver.url, match="Python") 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_html.py:556: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:39383' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('bs4',), io = 'http://127.0.0.1:39383', match = 'Python', attrs = None 636s encoding = None, displayed_only = True, extract_links = None 636s storage_options = None 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('Python'), retained = None, flav = 'bs4' 636s parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s from bs4 import BeautifulSoup 636s 636s > bdoc = self._setup_build_doc() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:653: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _setup_build_doc(self): 636s > raw_text = _read(self.io, self.encoding, self.storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:645: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s obj = 'http://127.0.0.1:39383', encoding = None, storage_options = None 636s 636s def _read( 636s obj: FilePath | BaseBuffer, 636s encoding: str | None, 636s storage_options: StorageOptions | None, 636s ) -> str | bytes: 636s """ 636s Try to read from a url, file or string. 636s 636s Parameters 636s ---------- 636s obj : str, unicode, path object, or file-like object 636s 636s Returns 636s ------- 636s raw_text : str 636s """ 636s text: str | bytes 636s if ( 636s is_url(obj) 636s or hasattr(obj, "read") 636s or (isinstance(obj, str) and file_exists(obj)) 636s ): 636s > with get_handle( 636s obj, "r", encoding=encoding, storage_options=storage_options 636s ) as handles: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:143: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:39383', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39383', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ___________________ TestReadHtml.test_multiple_matches[lxml] ___________________ 636s 636s self = 636s python_docs = '\n \n \n
\n

lists all sections and subsections

\n
\n ' 636s httpserver = , started 133469829940928)> 636s flavor_read_html = functools.partial(, flavor='lxml') 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_multiple_matches(self, python_docs, httpserver, flavor_read_html): 636s httpserver.serve_content(content=python_docs) 636s > dfs = flavor_read_html(httpserver.url, match="Python") 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_html.py:556: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:36621' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('lxml',), io = 'http://127.0.0.1:36621', match = 'Python' 636s attrs = None, encoding = None, displayed_only = True, extract_links = None 636s storage_options = None 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('Python'), retained = None, flav = 'lxml' 636s parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s r = parse(f.handle, parser=parser) 636s else: 636s # try to parse the input in the simplest way 636s r = parse(self.io, parser=parser) 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s except (UnicodeDecodeError, OSError) as e: 636s # if the input is a blob of html goop 636s if not is_url(self.io): 636s r = fromstring(self.io, parser=parser) 636s 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s else: 636s > raise e 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:806: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s > with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:785: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:36621', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:36621', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ___________________ TestReadHtml.test_python_docs_table[bs4] ___________________ 636s 636s self = 636s python_docs = '\n \n \n
\n

lists all sections and subsections

\n
\n ' 636s httpserver = , started 133469838333632)> 636s flavor_read_html = functools.partial(, flavor='bs4') 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_python_docs_table(self, python_docs, httpserver, flavor_read_html): 636s httpserver.serve_content(content=python_docs) 636s > dfs = flavor_read_html(httpserver.url, match="Python") 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_html.py:563: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:37083' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('bs4',), io = 'http://127.0.0.1:37083', match = 'Python', attrs = None 636s encoding = None, displayed_only = True, extract_links = None 636s storage_options = None 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('Python'), retained = None, flav = 'bs4' 636s parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s from bs4 import BeautifulSoup 636s 636s > bdoc = self._setup_build_doc() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:653: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _setup_build_doc(self): 636s > raw_text = _read(self.io, self.encoding, self.storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:645: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s obj = 'http://127.0.0.1:37083', encoding = None, storage_options = None 636s 636s def _read( 636s obj: FilePath | BaseBuffer, 636s encoding: str | None, 636s storage_options: StorageOptions | None, 636s ) -> str | bytes: 636s """ 636s Try to read from a url, file or string. 636s 636s Parameters 636s ---------- 636s obj : str, unicode, path object, or file-like object 636s 636s Returns 636s ------- 636s raw_text : str 636s """ 636s text: str | bytes 636s if ( 636s is_url(obj) 636s or hasattr(obj, "read") 636s or (isinstance(obj, str) and file_exists(obj)) 636s ): 636s > with get_handle( 636s obj, "r", encoding=encoding, storage_options=storage_options 636s ) as handles: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:143: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:37083', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:37083', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s __________________ TestReadHtml.test_python_docs_table[lxml] ___________________ 636s 636s self = 636s python_docs = '\n \n \n
\n

lists all sections and subsections

\n
\n ' 636s httpserver = , started 133469821548224)> 636s flavor_read_html = functools.partial(, flavor='lxml') 636s 636s @pytest.mark.network 636s @pytest.mark.single_cpu 636s def test_python_docs_table(self, python_docs, httpserver, flavor_read_html): 636s httpserver.serve_content(content=python_docs) 636s > dfs = flavor_read_html(httpserver.url, match="Python") 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_html.py:563: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:46329' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('lxml',), io = 'http://127.0.0.1:46329', match = 'Python' 636s attrs = None, encoding = None, displayed_only = True, extract_links = None 636s storage_options = None 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('Python'), retained = None, flav = 'lxml' 636s parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s r = parse(f.handle, parser=parser) 636s else: 636s # try to parse the input in the simplest way 636s r = parse(self.io, parser=parser) 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s except (UnicodeDecodeError, OSError) as e: 636s # if the input is a blob of html goop 636s if not is_url(self.io): 636s r = fromstring(self.io, parser=parser) 636s 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s else: 636s > raise e 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:806: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s > with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:785: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:46329', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46329', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______________ test_request_headers[None-csv_responder-read_csv] _______________ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469821548224)> 636s storage_options = None 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39705' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39705' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:39705', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:39705', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:39705', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39705', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________ test_request_headers[None-json_responder-read_json] ______________ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469864560320)> 636s storage_options = None 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:42559' 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "path_or_buf", 636s ) 636s def read_json( 636s path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], 636s *, 636s orient: str | None = None, 636s typ: Literal["frame", "series"] = "frame", 636s dtype: DtypeArg | None = None, 636s convert_axes: bool | None = None, 636s convert_dates: bool | list[str] = True, 636s keep_default_dates: bool = True, 636s precise_float: bool = False, 636s date_unit: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s lines: bool = False, 636s chunksize: int | None = None, 636s compression: CompressionOptions = "infer", 636s nrows: int | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> DataFrame | Series | JsonReader: 636s """ 636s Convert a JSON string to pandas object. 636s 636s Parameters 636s ---------- 636s path_or_buf : a valid JSON str, path object or file-like object 636s Any valid string path is acceptable. The string could be a URL. Valid 636s URL schemes include http, ftp, s3, and file. For file URLs, a host is 636s expected. A local file could be: 636s ``file://localhost/path/to/table.json``. 636s 636s If you want to pass in a path object, pandas accepts any 636s ``os.PathLike``. 636s 636s By file-like object, we refer to objects with a ``read()`` method, 636s such as a file handle (e.g. via builtin ``open`` function) 636s or ``StringIO``. 636s 636s .. deprecated:: 2.1.0 636s Passing json literal strings is deprecated. 636s 636s orient : str, optional 636s Indication of expected JSON string format. 636s Compatible JSON strings can be produced by ``to_json()`` with a 636s corresponding orient value. 636s The set of possible orients is: 636s 636s - ``'split'`` : dict like 636s ``{{index -> [index], columns -> [columns], data -> [values]}}`` 636s - ``'records'`` : list like 636s ``[{{column -> value}}, ... , {{column -> value}}]`` 636s - ``'index'`` : dict like ``{{index -> {{column -> value}}}}`` 636s - ``'columns'`` : dict like ``{{column -> {{index -> value}}}}`` 636s - ``'values'`` : just the values array 636s - ``'table'`` : dict like ``{{'schema': {{schema}}, 'data': {{data}}}}`` 636s 636s The allowed and default values depend on the value 636s of the `typ` parameter. 636s 636s * when ``typ == 'series'``, 636s 636s - allowed orients are ``{{'split','records','index'}}`` 636s - default is ``'index'`` 636s - The Series index must be unique for orient ``'index'``. 636s 636s * when ``typ == 'frame'``, 636s 636s - allowed orients are ``{{'split','records','index', 636s 'columns','values', 'table'}}`` 636s - default is ``'columns'`` 636s - The DataFrame index must be unique for orients ``'index'`` and 636s ``'columns'``. 636s - The DataFrame columns must be unique for orients ``'index'``, 636s ``'columns'``, and ``'records'``. 636s 636s typ : {{'frame', 'series'}}, default 'frame' 636s The type of object to recover. 636s 636s dtype : bool or dict, default None 636s If True, infer dtypes; if a dict of column to dtype, then use those; 636s if False, then don't infer dtypes at all, applies only to the data. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_axes : bool, default None 636s Try to convert the axes to the proper dtypes. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_dates : bool or list of str, default True 636s If True then default datelike columns may be converted (depending on 636s keep_default_dates). 636s If False, no dates will be converted. 636s If a list of column names, then those columns will be converted and 636s default datelike columns may also be converted (depending on 636s keep_default_dates). 636s 636s keep_default_dates : bool, default True 636s If parsing dates (convert_dates is not False), then try to parse the 636s default datelike columns. 636s A column label is datelike if 636s 636s * it ends with ``'_at'``, 636s 636s * it ends with ``'_time'``, 636s 636s * it begins with ``'timestamp'``, 636s 636s * it is ``'modified'``, or 636s 636s * it is ``'date'``. 636s 636s precise_float : bool, default False 636s Set to enable usage of higher precision (strtod) function when 636s decoding string to double values. Default (False) is to use fast but 636s less precise builtin functionality. 636s 636s date_unit : str, default None 636s The timestamp unit to detect if converting dates. The default behaviour 636s is to try and detect the correct precision, but if this is not desired 636s then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds, 636s milliseconds, microseconds or nanoseconds respectively. 636s 636s encoding : str, default is 'utf-8' 636s The encoding to use to decode py3 bytes. 636s 636s encoding_errors : str, optional, default "strict" 636s How encoding errors are treated. `List of possible values 636s `_ . 636s 636s .. versionadded:: 1.3.0 636s 636s lines : bool, default False 636s Read the file as a json object per line. 636s 636s chunksize : int, optional 636s Return JsonReader object for iteration. 636s See the `line-delimited json docs 636s `_ 636s for more information on ``chunksize``. 636s This can only be passed if `lines=True`. 636s If this is None, the file will be read into memory all at once. 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s nrows : int, optional 636s The number of lines from the line-delimited jsonfile that has to be read. 636s This can only be passed if `lines=True`. 636s If this is None, all the rows will be returned. 636s 636s {storage_options} 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s engine : {{"ujson", "pyarrow"}}, default "ujson" 636s Parser engine to use. The ``"pyarrow"`` engine is only available when 636s ``lines=True``. 636s 636s .. versionadded:: 2.0 636s 636s Returns 636s ------- 636s Series, DataFrame, or pandas.api.typing.JsonReader 636s A JsonReader is returned when ``chunksize`` is not ``0`` or ``None``. 636s Otherwise, the type returned depends on the value of ``typ``. 636s 636s See Also 636s -------- 636s DataFrame.to_json : Convert a DataFrame to a JSON string. 636s Series.to_json : Convert a Series to a JSON string. 636s json_normalize : Normalize semi-structured JSON data into a flat table. 636s 636s Notes 636s ----- 636s Specific to ``orient='table'``, if a :class:`DataFrame` with a literal 636s :class:`Index` name of `index` gets written with :func:`to_json`, the 636s subsequent read operation will incorrectly set the :class:`Index` name to 636s ``None``. This is because `index` is also used by :func:`DataFrame.to_json` 636s to denote a missing :class:`Index` name, and the subsequent 636s :func:`read_json` operation cannot distinguish between the two. The same 636s limitation is encountered with a :class:`MultiIndex` and any names 636s beginning with ``'level_'``. 636s 636s Examples 636s -------- 636s >>> from io import StringIO 636s >>> df = pd.DataFrame([['a', 'b'], ['c', 'd']], 636s ... index=['row 1', 'row 2'], 636s ... columns=['col 1', 'col 2']) 636s 636s Encoding/decoding a Dataframe using ``'split'`` formatted JSON: 636s 636s >>> df.to_json(orient='split') 636s '\ 636s {{\ 636s "columns":["col 1","col 2"],\ 636s "index":["row 1","row 2"],\ 636s "data":[["a","b"],["c","d"]]\ 636s }}\ 636s ' 636s >>> pd.read_json(StringIO(_), orient='split') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'index'`` formatted JSON: 636s 636s >>> df.to_json(orient='index') 636s '{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}' 636s 636s >>> pd.read_json(StringIO(_), orient='index') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'records'`` formatted JSON. 636s Note that index labels are not preserved with this encoding. 636s 636s >>> df.to_json(orient='records') 636s '[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]' 636s >>> pd.read_json(StringIO(_), orient='records') 636s col 1 col 2 636s 0 a b 636s 1 c d 636s 636s Encoding with Table Schema 636s 636s >>> df.to_json(orient='table') 636s '\ 636s {{"schema":{{"fields":[\ 636s {{"name":"index","type":"string"}},\ 636s {{"name":"col 1","type":"string"}},\ 636s {{"name":"col 2","type":"string"}}],\ 636s "primaryKey":["index"],\ 636s "pandas_version":"1.4.0"}},\ 636s "data":[\ 636s {{"index":"row 1","col 1":"a","col 2":"b"}},\ 636s {{"index":"row 2","col 1":"c","col 2":"d"}}]\ 636s }}\ 636s ' 636s 636s The following example uses ``dtype_backend="numpy_nullable"`` 636s 636s >>> data = '''{{"index": {{"0": 0, "1": 1}}, 636s ... "a": {{"0": 1, "1": null}}, 636s ... "b": {{"0": 2.5, "1": 4.5}}, 636s ... "c": {{"0": true, "1": false}}, 636s ... "d": {{"0": "a", "1": "b"}}, 636s ... "e": {{"0": 1577.2, "1": 1577.1}}}}''' 636s >>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable") 636s index a b c d e 636s 0 0 1 2.5 True a 1577.2 636s 1 1 4.5 False b 1577.1 636s """ 636s if orient == "table" and dtype: 636s raise ValueError("cannot pass both dtype and orient='table'") 636s if orient == "table" and convert_axes: 636s raise ValueError("cannot pass both convert_axes and orient='table'") 636s 636s check_dtype_backend(dtype_backend) 636s 636s if dtype is None and orient != "table": 636s # error: Incompatible types in assignment (expression has type "bool", variable 636s # has type "Union[ExtensionDtype, str, dtype[Any], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object], Dict[Hashable, 636s # Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object]]], None]") 636s dtype = True # type: ignore[assignment] 636s if convert_axes is None and orient != "table": 636s convert_axes = True 636s 636s > json_reader = JsonReader( 636s path_or_buf, 636s orient=orient, 636s typ=typ, 636s dtype=dtype, 636s convert_axes=convert_axes, 636s convert_dates=convert_dates, 636s keep_default_dates=keep_default_dates, 636s precise_float=precise_float, 636s date_unit=date_unit, 636s encoding=encoding, 636s lines=lines, 636s chunksize=chunksize, 636s compression=compression, 636s nrows=nrows, 636s storage_options=storage_options, 636s encoding_errors=encoding_errors, 636s dtype_backend=dtype_backend, 636s engine=engine, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:791: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:42559', orient = None, typ = 'frame' 636s dtype = True, convert_axes = True, convert_dates = True 636s keep_default_dates = True, precise_float = False, date_unit = None 636s encoding = None, lines = False, chunksize = None, compression = 'infer' 636s nrows = None, storage_options = None, encoding_errors = 'strict' 636s dtype_backend = , engine = 'ujson' 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s orient, 636s typ: FrameSeriesStrT, 636s dtype, 636s convert_axes: bool | None, 636s convert_dates, 636s keep_default_dates: bool, 636s precise_float: bool, 636s date_unit, 636s encoding, 636s lines: bool, 636s chunksize: int | None, 636s compression: CompressionOptions, 636s nrows: int | None, 636s storage_options: StorageOptions | None = None, 636s encoding_errors: str | None = "strict", 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> None: 636s self.orient = orient 636s self.typ = typ 636s self.dtype = dtype 636s self.convert_axes = convert_axes 636s self.convert_dates = convert_dates 636s self.keep_default_dates = keep_default_dates 636s self.precise_float = precise_float 636s self.date_unit = date_unit 636s self.encoding = encoding 636s self.engine = engine 636s self.compression = compression 636s self.storage_options = storage_options 636s self.lines = lines 636s self.chunksize = chunksize 636s self.nrows_seen = 0 636s self.nrows = nrows 636s self.encoding_errors = encoding_errors 636s self.handles: IOHandles[str] | None = None 636s self.dtype_backend = dtype_backend 636s 636s if self.engine not in {"pyarrow", "ujson"}: 636s raise ValueError( 636s f"The engine type {self.engine} is currently not supported." 636s ) 636s if self.chunksize is not None: 636s self.chunksize = validate_integer("chunksize", self.chunksize, 1) 636s if not self.lines: 636s raise ValueError("chunksize can only be passed if lines=True") 636s if self.engine == "pyarrow": 636s raise ValueError( 636s "currently pyarrow engine doesn't support chunksize parameter" 636s ) 636s if self.nrows is not None: 636s self.nrows = validate_integer("nrows", self.nrows, 0) 636s if not self.lines: 636s raise ValueError("nrows can only be passed if lines=True") 636s if ( 636s isinstance(filepath_or_buffer, str) 636s and not self.lines 636s and "\n" in filepath_or_buffer 636s ): 636s warnings.warn( 636s "Passing literal json to 'read_json' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s if self.engine == "pyarrow": 636s if not self.lines: 636s raise ValueError( 636s "currently pyarrow engine only supports " 636s "the line-delimited JSON format" 636s ) 636s self.data = filepath_or_buffer 636s elif self.engine == "ujson": 636s > data = self._get_data_from_filepath(filepath_or_buffer) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:904: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:42559' 636s 636s def _get_data_from_filepath(self, filepath_or_buffer): 636s """ 636s The function read_json accepts three input types: 636s 1. filepath (string-like) 636s 2. file-like object (e.g. open file object, StringIO) 636s 3. JSON string 636s 636s This method turns (1) into (2) to simplify the rest of the processing. 636s It returns input types (2) and (3) unchanged. 636s 636s It raises FileNotFoundError if the input is a string ending in 636s one of .json, .json.gz, .json.bz2, etc. but no such file exists. 636s """ 636s # if it is a string but the file does not exist, it might be a JSON string 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s if ( 636s not isinstance(filepath_or_buffer, str) 636s or is_url(filepath_or_buffer) 636s or is_fsspec_url(filepath_or_buffer) 636s or file_exists(filepath_or_buffer) 636s ): 636s > self.handles = get_handle( 636s filepath_or_buffer, 636s "r", 636s encoding=self.encoding, 636s compression=self.compression, 636s storage_options=self.storage_options, 636s errors=self.encoding_errors, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:944: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:42559', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:42559', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______________ test_request_headers[None-html_responder-] ______________ 636s 636s responder = 636s read_method = at 0x7963fd5ca980> 636s httpserver = , started 133469821548224)> 636s storage_options = None 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = ('http://127.0.0.1:34277',), kwargs = {'storage_options': None} 636s 636s > lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:93: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:34277' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('lxml', 'bs4'), io = 'http://127.0.0.1:34277', match = '.+' 636s attrs = None, encoding = None, displayed_only = True, extract_links = None 636s storage_options = None 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('.+'), retained = None, flav = 'lxml' 636s parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s r = parse(f.handle, parser=parser) 636s else: 636s # try to parse the input in the simplest way 636s r = parse(self.io, parser=parser) 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s except (UnicodeDecodeError, OSError) as e: 636s # if the input is a blob of html goop 636s if not is_url(self.io): 636s r = fromstring(self.io, parser=parser) 636s 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s else: 636s > raise e 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:806: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s > with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:785: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:34277', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:34277', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ____________ test_request_headers[None-pickle_respnder-read_pickle] ____________ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469846726336)> 636s storage_options = None 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46129', compression = 'infer' 636s storage_options = None 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "filepath_or_buffer", 636s ) 636s def read_pickle( 636s filepath_or_buffer: FilePath | ReadPickleBuffer, 636s compression: CompressionOptions = "infer", 636s storage_options: StorageOptions | None = None, 636s ) -> DataFrame | Series: 636s """ 636s Load pickled pandas object (or any object) from file. 636s 636s .. warning:: 636s 636s Loading pickled data received from untrusted sources can be 636s unsafe. See `here `__. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a binary ``readlines()`` function. 636s Also accepts URL. URL is not limited to S3 and GCS. 636s 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s {storage_options} 636s 636s Returns 636s ------- 636s same type as object stored in file 636s 636s See Also 636s -------- 636s DataFrame.to_pickle : Pickle (serialize) DataFrame object to file. 636s Series.to_pickle : Pickle (serialize) Series object to file. 636s read_hdf : Read HDF5 file into a DataFrame. 636s read_sql : Read SQL query or database table into a DataFrame. 636s read_parquet : Load a parquet object, returning a DataFrame. 636s 636s Notes 636s ----- 636s read_pickle is only guaranteed to be backwards compatible to pandas 0.20.3 636s provided the object was serialized with to_pickle. 636s 636s Examples 636s -------- 636s >>> original_df = pd.DataFrame( 636s ... {{"foo": range(5), "bar": range(5, 10)}} 636s ... ) # doctest: +SKIP 636s >>> original_df # doctest: +SKIP 636s foo bar 636s 0 0 5 636s 1 1 6 636s 2 2 7 636s 3 3 8 636s 4 4 9 636s >>> pd.to_pickle(original_df, "./dummy.pkl") # doctest: +SKIP 636s 636s >>> unpickled_df = pd.read_pickle("./dummy.pkl") # doctest: +SKIP 636s >>> unpickled_df # doctest: +SKIP 636s foo bar 636s 0 0 5 636s 1 1 6 636s 2 2 7 636s 3 3 8 636s 4 4 9 636s """ 636s excs_to_catch = (AttributeError, ImportError, ModuleNotFoundError, TypeError) 636s > with get_handle( 636s filepath_or_buffer, 636s "rb", 636s compression=compression, 636s is_text=False, 636s storage_options=storage_options, 636s ) as handles: 636s 636s /usr/lib/python3/dist-packages/pandas/io/pickle.py:185: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:46129', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46129', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ____________ test_request_headers[None-stata_responder-read_stata] _____________ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469838333632)> 636s storage_options = None 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:37829' 636s 636s @Appender(_read_stata_doc) 636s def read_stata( 636s filepath_or_buffer: FilePath | ReadBuffer[bytes], 636s *, 636s convert_dates: bool = True, 636s convert_categoricals: bool = True, 636s index_col: str | None = None, 636s convert_missing: bool = False, 636s preserve_dtypes: bool = True, 636s columns: Sequence[str] | None = None, 636s order_categoricals: bool = True, 636s chunksize: int | None = None, 636s iterator: bool = False, 636s compression: CompressionOptions = "infer", 636s storage_options: StorageOptions | None = None, 636s ) -> DataFrame | StataReader: 636s reader = StataReader( 636s filepath_or_buffer, 636s convert_dates=convert_dates, 636s convert_categoricals=convert_categoricals, 636s index_col=index_col, 636s convert_missing=convert_missing, 636s preserve_dtypes=preserve_dtypes, 636s columns=columns, 636s order_categoricals=order_categoricals, 636s chunksize=chunksize, 636s storage_options=storage_options, 636s compression=compression, 636s ) 636s 636s if iterator or chunksize: 636s return reader 636s 636s with reader: 636s > return reader.read() 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:2113: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , nrows = None 636s convert_dates = None, convert_categoricals = None, index_col = None 636s convert_missing = None, preserve_dtypes = None, columns = None 636s order_categoricals = None 636s 636s @Appender(_read_method_doc) 636s def read( 636s self, 636s nrows: int | None = None, 636s convert_dates: bool | None = None, 636s convert_categoricals: bool | None = None, 636s index_col: str | None = None, 636s convert_missing: bool | None = None, 636s preserve_dtypes: bool | None = None, 636s columns: Sequence[str] | None = None, 636s order_categoricals: bool | None = None, 636s ) -> DataFrame: 636s > self._ensure_open() 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:1687: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _ensure_open(self) -> None: 636s """ 636s Ensure the file has been opened and its header data read. 636s """ 636s if not hasattr(self, "_path_or_buf"): 636s > self._open_file() 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:1179: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _open_file(self) -> None: 636s """ 636s Open the file (with compression options, etc.), and read header information. 636s """ 636s if not self._entered: 636s warnings.warn( 636s "StataReader is being used without using a context manager. " 636s "Using StataReader as a context manager is the only supported method.", 636s ResourceWarning, 636s stacklevel=find_stack_level(), 636s ) 636s > handles = get_handle( 636s self._original_path_or_buf, 636s "rb", 636s storage_options=self._storage_options, 636s is_text=False, 636s compression=self._compression, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:1192: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:37829', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:37829', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb', storage_options = {} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _____________ test_request_headers[None-gz_csv_responder-read_csv] _____________ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469829940928)> 636s storage_options = {'Content-Encoding': 'gzip'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43173' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43173' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:43173', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:43173', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:43173', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43173', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r' 636s storage_options = {'Content-Encoding': 'gzip'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ____________ test_request_headers[None-gz_json_responder-read_json] ____________ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469838333632)> 636s storage_options = {'Content-Encoding': 'gzip'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:32817' 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "path_or_buf", 636s ) 636s def read_json( 636s path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], 636s *, 636s orient: str | None = None, 636s typ: Literal["frame", "series"] = "frame", 636s dtype: DtypeArg | None = None, 636s convert_axes: bool | None = None, 636s convert_dates: bool | list[str] = True, 636s keep_default_dates: bool = True, 636s precise_float: bool = False, 636s date_unit: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s lines: bool = False, 636s chunksize: int | None = None, 636s compression: CompressionOptions = "infer", 636s nrows: int | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> DataFrame | Series | JsonReader: 636s """ 636s Convert a JSON string to pandas object. 636s 636s Parameters 636s ---------- 636s path_or_buf : a valid JSON str, path object or file-like object 636s Any valid string path is acceptable. The string could be a URL. Valid 636s URL schemes include http, ftp, s3, and file. For file URLs, a host is 636s expected. A local file could be: 636s ``file://localhost/path/to/table.json``. 636s 636s If you want to pass in a path object, pandas accepts any 636s ``os.PathLike``. 636s 636s By file-like object, we refer to objects with a ``read()`` method, 636s such as a file handle (e.g. via builtin ``open`` function) 636s or ``StringIO``. 636s 636s .. deprecated:: 2.1.0 636s Passing json literal strings is deprecated. 636s 636s orient : str, optional 636s Indication of expected JSON string format. 636s Compatible JSON strings can be produced by ``to_json()`` with a 636s corresponding orient value. 636s The set of possible orients is: 636s 636s - ``'split'`` : dict like 636s ``{{index -> [index], columns -> [columns], data -> [values]}}`` 636s - ``'records'`` : list like 636s ``[{{column -> value}}, ... , {{column -> value}}]`` 636s - ``'index'`` : dict like ``{{index -> {{column -> value}}}}`` 636s - ``'columns'`` : dict like ``{{column -> {{index -> value}}}}`` 636s - ``'values'`` : just the values array 636s - ``'table'`` : dict like ``{{'schema': {{schema}}, 'data': {{data}}}}`` 636s 636s The allowed and default values depend on the value 636s of the `typ` parameter. 636s 636s * when ``typ == 'series'``, 636s 636s - allowed orients are ``{{'split','records','index'}}`` 636s - default is ``'index'`` 636s - The Series index must be unique for orient ``'index'``. 636s 636s * when ``typ == 'frame'``, 636s 636s - allowed orients are ``{{'split','records','index', 636s 'columns','values', 'table'}}`` 636s - default is ``'columns'`` 636s - The DataFrame index must be unique for orients ``'index'`` and 636s ``'columns'``. 636s - The DataFrame columns must be unique for orients ``'index'``, 636s ``'columns'``, and ``'records'``. 636s 636s typ : {{'frame', 'series'}}, default 'frame' 636s The type of object to recover. 636s 636s dtype : bool or dict, default None 636s If True, infer dtypes; if a dict of column to dtype, then use those; 636s if False, then don't infer dtypes at all, applies only to the data. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_axes : bool, default None 636s Try to convert the axes to the proper dtypes. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_dates : bool or list of str, default True 636s If True then default datelike columns may be converted (depending on 636s keep_default_dates). 636s If False, no dates will be converted. 636s If a list of column names, then those columns will be converted and 636s default datelike columns may also be converted (depending on 636s keep_default_dates). 636s 636s keep_default_dates : bool, default True 636s If parsing dates (convert_dates is not False), then try to parse the 636s default datelike columns. 636s A column label is datelike if 636s 636s * it ends with ``'_at'``, 636s 636s * it ends with ``'_time'``, 636s 636s * it begins with ``'timestamp'``, 636s 636s * it is ``'modified'``, or 636s 636s * it is ``'date'``. 636s 636s precise_float : bool, default False 636s Set to enable usage of higher precision (strtod) function when 636s decoding string to double values. Default (False) is to use fast but 636s less precise builtin functionality. 636s 636s date_unit : str, default None 636s The timestamp unit to detect if converting dates. The default behaviour 636s is to try and detect the correct precision, but if this is not desired 636s then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds, 636s milliseconds, microseconds or nanoseconds respectively. 636s 636s encoding : str, default is 'utf-8' 636s The encoding to use to decode py3 bytes. 636s 636s encoding_errors : str, optional, default "strict" 636s How encoding errors are treated. `List of possible values 636s `_ . 636s 636s .. versionadded:: 1.3.0 636s 636s lines : bool, default False 636s Read the file as a json object per line. 636s 636s chunksize : int, optional 636s Return JsonReader object for iteration. 636s See the `line-delimited json docs 636s `_ 636s for more information on ``chunksize``. 636s This can only be passed if `lines=True`. 636s If this is None, the file will be read into memory all at once. 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s nrows : int, optional 636s The number of lines from the line-delimited jsonfile that has to be read. 636s This can only be passed if `lines=True`. 636s If this is None, all the rows will be returned. 636s 636s {storage_options} 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s engine : {{"ujson", "pyarrow"}}, default "ujson" 636s Parser engine to use. The ``"pyarrow"`` engine is only available when 636s ``lines=True``. 636s 636s .. versionadded:: 2.0 636s 636s Returns 636s ------- 636s Series, DataFrame, or pandas.api.typing.JsonReader 636s A JsonReader is returned when ``chunksize`` is not ``0`` or ``None``. 636s Otherwise, the type returned depends on the value of ``typ``. 636s 636s See Also 636s -------- 636s DataFrame.to_json : Convert a DataFrame to a JSON string. 636s Series.to_json : Convert a Series to a JSON string. 636s json_normalize : Normalize semi-structured JSON data into a flat table. 636s 636s Notes 636s ----- 636s Specific to ``orient='table'``, if a :class:`DataFrame` with a literal 636s :class:`Index` name of `index` gets written with :func:`to_json`, the 636s subsequent read operation will incorrectly set the :class:`Index` name to 636s ``None``. This is because `index` is also used by :func:`DataFrame.to_json` 636s to denote a missing :class:`Index` name, and the subsequent 636s :func:`read_json` operation cannot distinguish between the two. The same 636s limitation is encountered with a :class:`MultiIndex` and any names 636s beginning with ``'level_'``. 636s 636s Examples 636s -------- 636s >>> from io import StringIO 636s >>> df = pd.DataFrame([['a', 'b'], ['c', 'd']], 636s ... index=['row 1', 'row 2'], 636s ... columns=['col 1', 'col 2']) 636s 636s Encoding/decoding a Dataframe using ``'split'`` formatted JSON: 636s 636s >>> df.to_json(orient='split') 636s '\ 636s {{\ 636s "columns":["col 1","col 2"],\ 636s "index":["row 1","row 2"],\ 636s "data":[["a","b"],["c","d"]]\ 636s }}\ 636s ' 636s >>> pd.read_json(StringIO(_), orient='split') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'index'`` formatted JSON: 636s 636s >>> df.to_json(orient='index') 636s '{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}' 636s 636s >>> pd.read_json(StringIO(_), orient='index') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'records'`` formatted JSON. 636s Note that index labels are not preserved with this encoding. 636s 636s >>> df.to_json(orient='records') 636s '[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]' 636s >>> pd.read_json(StringIO(_), orient='records') 636s col 1 col 2 636s 0 a b 636s 1 c d 636s 636s Encoding with Table Schema 636s 636s >>> df.to_json(orient='table') 636s '\ 636s {{"schema":{{"fields":[\ 636s {{"name":"index","type":"string"}},\ 636s {{"name":"col 1","type":"string"}},\ 636s {{"name":"col 2","type":"string"}}],\ 636s "primaryKey":["index"],\ 636s "pandas_version":"1.4.0"}},\ 636s "data":[\ 636s {{"index":"row 1","col 1":"a","col 2":"b"}},\ 636s {{"index":"row 2","col 1":"c","col 2":"d"}}]\ 636s }}\ 636s ' 636s 636s The following example uses ``dtype_backend="numpy_nullable"`` 636s 636s >>> data = '''{{"index": {{"0": 0, "1": 1}}, 636s ... "a": {{"0": 1, "1": null}}, 636s ... "b": {{"0": 2.5, "1": 4.5}}, 636s ... "c": {{"0": true, "1": false}}, 636s ... "d": {{"0": "a", "1": "b"}}, 636s ... "e": {{"0": 1577.2, "1": 1577.1}}}}''' 636s >>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable") 636s index a b c d e 636s 0 0 1 2.5 True a 1577.2 636s 1 1 4.5 False b 1577.1 636s """ 636s if orient == "table" and dtype: 636s raise ValueError("cannot pass both dtype and orient='table'") 636s if orient == "table" and convert_axes: 636s raise ValueError("cannot pass both convert_axes and orient='table'") 636s 636s check_dtype_backend(dtype_backend) 636s 636s if dtype is None and orient != "table": 636s # error: Incompatible types in assignment (expression has type "bool", variable 636s # has type "Union[ExtensionDtype, str, dtype[Any], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object], Dict[Hashable, 636s # Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object]]], None]") 636s dtype = True # type: ignore[assignment] 636s if convert_axes is None and orient != "table": 636s convert_axes = True 636s 636s > json_reader = JsonReader( 636s path_or_buf, 636s orient=orient, 636s typ=typ, 636s dtype=dtype, 636s convert_axes=convert_axes, 636s convert_dates=convert_dates, 636s keep_default_dates=keep_default_dates, 636s precise_float=precise_float, 636s date_unit=date_unit, 636s encoding=encoding, 636s lines=lines, 636s chunksize=chunksize, 636s compression=compression, 636s nrows=nrows, 636s storage_options=storage_options, 636s encoding_errors=encoding_errors, 636s dtype_backend=dtype_backend, 636s engine=engine, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:791: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:32817', orient = None, typ = 'frame' 636s dtype = True, convert_axes = True, convert_dates = True 636s keep_default_dates = True, precise_float = False, date_unit = None 636s encoding = None, lines = False, chunksize = None, compression = 'infer' 636s nrows = None, storage_options = {'Content-Encoding': 'gzip'} 636s encoding_errors = 'strict', dtype_backend = , engine = 'ujson' 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s orient, 636s typ: FrameSeriesStrT, 636s dtype, 636s convert_axes: bool | None, 636s convert_dates, 636s keep_default_dates: bool, 636s precise_float: bool, 636s date_unit, 636s encoding, 636s lines: bool, 636s chunksize: int | None, 636s compression: CompressionOptions, 636s nrows: int | None, 636s storage_options: StorageOptions | None = None, 636s encoding_errors: str | None = "strict", 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> None: 636s self.orient = orient 636s self.typ = typ 636s self.dtype = dtype 636s self.convert_axes = convert_axes 636s self.convert_dates = convert_dates 636s self.keep_default_dates = keep_default_dates 636s self.precise_float = precise_float 636s self.date_unit = date_unit 636s self.encoding = encoding 636s self.engine = engine 636s self.compression = compression 636s self.storage_options = storage_options 636s self.lines = lines 636s self.chunksize = chunksize 636s self.nrows_seen = 0 636s self.nrows = nrows 636s self.encoding_errors = encoding_errors 636s self.handles: IOHandles[str] | None = None 636s self.dtype_backend = dtype_backend 636s 636s if self.engine not in {"pyarrow", "ujson"}: 636s raise ValueError( 636s f"The engine type {self.engine} is currently not supported." 636s ) 636s if self.chunksize is not None: 636s self.chunksize = validate_integer("chunksize", self.chunksize, 1) 636s if not self.lines: 636s raise ValueError("chunksize can only be passed if lines=True") 636s if self.engine == "pyarrow": 636s raise ValueError( 636s "currently pyarrow engine doesn't support chunksize parameter" 636s ) 636s if self.nrows is not None: 636s self.nrows = validate_integer("nrows", self.nrows, 0) 636s if not self.lines: 636s raise ValueError("nrows can only be passed if lines=True") 636s if ( 636s isinstance(filepath_or_buffer, str) 636s and not self.lines 636s and "\n" in filepath_or_buffer 636s ): 636s warnings.warn( 636s "Passing literal json to 'read_json' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s if self.engine == "pyarrow": 636s if not self.lines: 636s raise ValueError( 636s "currently pyarrow engine only supports " 636s "the line-delimited JSON format" 636s ) 636s self.data = filepath_or_buffer 636s elif self.engine == "ujson": 636s > data = self._get_data_from_filepath(filepath_or_buffer) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:904: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:32817' 636s 636s def _get_data_from_filepath(self, filepath_or_buffer): 636s """ 636s The function read_json accepts three input types: 636s 1. filepath (string-like) 636s 2. file-like object (e.g. open file object, StringIO) 636s 3. JSON string 636s 636s This method turns (1) into (2) to simplify the rest of the processing. 636s It returns input types (2) and (3) unchanged. 636s 636s It raises FileNotFoundError if the input is a string ending in 636s one of .json, .json.gz, .json.bz2, etc. but no such file exists. 636s """ 636s # if it is a string but the file does not exist, it might be a JSON string 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s if ( 636s not isinstance(filepath_or_buffer, str) 636s or is_url(filepath_or_buffer) 636s or is_fsspec_url(filepath_or_buffer) 636s or file_exists(filepath_or_buffer) 636s ): 636s > self.handles = get_handle( 636s filepath_or_buffer, 636s "r", 636s encoding=self.encoding, 636s compression=self.compression, 636s storage_options=self.storage_options, 636s errors=self.encoding_errors, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:944: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:32817', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:32817', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r' 636s storage_options = {'Content-Encoding': 'gzip'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ________ test_request_headers[storage_options1-csv_responder-read_csv] _________ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469846726336)> 636s storage_options = {'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:41413' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:41413' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:41413', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:41413', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:41413', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:41413', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r' 636s storage_options = {'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______ test_request_headers[storage_options1-json_responder-read_json] ________ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469821548224)> 636s storage_options = {'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:34401' 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "path_or_buf", 636s ) 636s def read_json( 636s path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], 636s *, 636s orient: str | None = None, 636s typ: Literal["frame", "series"] = "frame", 636s dtype: DtypeArg | None = None, 636s convert_axes: bool | None = None, 636s convert_dates: bool | list[str] = True, 636s keep_default_dates: bool = True, 636s precise_float: bool = False, 636s date_unit: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s lines: bool = False, 636s chunksize: int | None = None, 636s compression: CompressionOptions = "infer", 636s nrows: int | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> DataFrame | Series | JsonReader: 636s """ 636s Convert a JSON string to pandas object. 636s 636s Parameters 636s ---------- 636s path_or_buf : a valid JSON str, path object or file-like object 636s Any valid string path is acceptable. The string could be a URL. Valid 636s URL schemes include http, ftp, s3, and file. For file URLs, a host is 636s expected. A local file could be: 636s ``file://localhost/path/to/table.json``. 636s 636s If you want to pass in a path object, pandas accepts any 636s ``os.PathLike``. 636s 636s By file-like object, we refer to objects with a ``read()`` method, 636s such as a file handle (e.g. via builtin ``open`` function) 636s or ``StringIO``. 636s 636s .. deprecated:: 2.1.0 636s Passing json literal strings is deprecated. 636s 636s orient : str, optional 636s Indication of expected JSON string format. 636s Compatible JSON strings can be produced by ``to_json()`` with a 636s corresponding orient value. 636s The set of possible orients is: 636s 636s - ``'split'`` : dict like 636s ``{{index -> [index], columns -> [columns], data -> [values]}}`` 636s - ``'records'`` : list like 636s ``[{{column -> value}}, ... , {{column -> value}}]`` 636s - ``'index'`` : dict like ``{{index -> {{column -> value}}}}`` 636s - ``'columns'`` : dict like ``{{column -> {{index -> value}}}}`` 636s - ``'values'`` : just the values array 636s - ``'table'`` : dict like ``{{'schema': {{schema}}, 'data': {{data}}}}`` 636s 636s The allowed and default values depend on the value 636s of the `typ` parameter. 636s 636s * when ``typ == 'series'``, 636s 636s - allowed orients are ``{{'split','records','index'}}`` 636s - default is ``'index'`` 636s - The Series index must be unique for orient ``'index'``. 636s 636s * when ``typ == 'frame'``, 636s 636s - allowed orients are ``{{'split','records','index', 636s 'columns','values', 'table'}}`` 636s - default is ``'columns'`` 636s - The DataFrame index must be unique for orients ``'index'`` and 636s ``'columns'``. 636s - The DataFrame columns must be unique for orients ``'index'``, 636s ``'columns'``, and ``'records'``. 636s 636s typ : {{'frame', 'series'}}, default 'frame' 636s The type of object to recover. 636s 636s dtype : bool or dict, default None 636s If True, infer dtypes; if a dict of column to dtype, then use those; 636s if False, then don't infer dtypes at all, applies only to the data. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_axes : bool, default None 636s Try to convert the axes to the proper dtypes. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_dates : bool or list of str, default True 636s If True then default datelike columns may be converted (depending on 636s keep_default_dates). 636s If False, no dates will be converted. 636s If a list of column names, then those columns will be converted and 636s default datelike columns may also be converted (depending on 636s keep_default_dates). 636s 636s keep_default_dates : bool, default True 636s If parsing dates (convert_dates is not False), then try to parse the 636s default datelike columns. 636s A column label is datelike if 636s 636s * it ends with ``'_at'``, 636s 636s * it ends with ``'_time'``, 636s 636s * it begins with ``'timestamp'``, 636s 636s * it is ``'modified'``, or 636s 636s * it is ``'date'``. 636s 636s precise_float : bool, default False 636s Set to enable usage of higher precision (strtod) function when 636s decoding string to double values. Default (False) is to use fast but 636s less precise builtin functionality. 636s 636s date_unit : str, default None 636s The timestamp unit to detect if converting dates. The default behaviour 636s is to try and detect the correct precision, but if this is not desired 636s then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds, 636s milliseconds, microseconds or nanoseconds respectively. 636s 636s encoding : str, default is 'utf-8' 636s The encoding to use to decode py3 bytes. 636s 636s encoding_errors : str, optional, default "strict" 636s How encoding errors are treated. `List of possible values 636s `_ . 636s 636s .. versionadded:: 1.3.0 636s 636s lines : bool, default False 636s Read the file as a json object per line. 636s 636s chunksize : int, optional 636s Return JsonReader object for iteration. 636s See the `line-delimited json docs 636s `_ 636s for more information on ``chunksize``. 636s This can only be passed if `lines=True`. 636s If this is None, the file will be read into memory all at once. 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s nrows : int, optional 636s The number of lines from the line-delimited jsonfile that has to be read. 636s This can only be passed if `lines=True`. 636s If this is None, all the rows will be returned. 636s 636s {storage_options} 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s engine : {{"ujson", "pyarrow"}}, default "ujson" 636s Parser engine to use. The ``"pyarrow"`` engine is only available when 636s ``lines=True``. 636s 636s .. versionadded:: 2.0 636s 636s Returns 636s ------- 636s Series, DataFrame, or pandas.api.typing.JsonReader 636s A JsonReader is returned when ``chunksize`` is not ``0`` or ``None``. 636s Otherwise, the type returned depends on the value of ``typ``. 636s 636s See Also 636s -------- 636s DataFrame.to_json : Convert a DataFrame to a JSON string. 636s Series.to_json : Convert a Series to a JSON string. 636s json_normalize : Normalize semi-structured JSON data into a flat table. 636s 636s Notes 636s ----- 636s Specific to ``orient='table'``, if a :class:`DataFrame` with a literal 636s :class:`Index` name of `index` gets written with :func:`to_json`, the 636s subsequent read operation will incorrectly set the :class:`Index` name to 636s ``None``. This is because `index` is also used by :func:`DataFrame.to_json` 636s to denote a missing :class:`Index` name, and the subsequent 636s :func:`read_json` operation cannot distinguish between the two. The same 636s limitation is encountered with a :class:`MultiIndex` and any names 636s beginning with ``'level_'``. 636s 636s Examples 636s -------- 636s >>> from io import StringIO 636s >>> df = pd.DataFrame([['a', 'b'], ['c', 'd']], 636s ... index=['row 1', 'row 2'], 636s ... columns=['col 1', 'col 2']) 636s 636s Encoding/decoding a Dataframe using ``'split'`` formatted JSON: 636s 636s >>> df.to_json(orient='split') 636s '\ 636s {{\ 636s "columns":["col 1","col 2"],\ 636s "index":["row 1","row 2"],\ 636s "data":[["a","b"],["c","d"]]\ 636s }}\ 636s ' 636s >>> pd.read_json(StringIO(_), orient='split') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'index'`` formatted JSON: 636s 636s >>> df.to_json(orient='index') 636s '{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}' 636s 636s >>> pd.read_json(StringIO(_), orient='index') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'records'`` formatted JSON. 636s Note that index labels are not preserved with this encoding. 636s 636s >>> df.to_json(orient='records') 636s '[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]' 636s >>> pd.read_json(StringIO(_), orient='records') 636s col 1 col 2 636s 0 a b 636s 1 c d 636s 636s Encoding with Table Schema 636s 636s >>> df.to_json(orient='table') 636s '\ 636s {{"schema":{{"fields":[\ 636s {{"name":"index","type":"string"}},\ 636s {{"name":"col 1","type":"string"}},\ 636s {{"name":"col 2","type":"string"}}],\ 636s "primaryKey":["index"],\ 636s "pandas_version":"1.4.0"}},\ 636s "data":[\ 636s {{"index":"row 1","col 1":"a","col 2":"b"}},\ 636s {{"index":"row 2","col 1":"c","col 2":"d"}}]\ 636s }}\ 636s ' 636s 636s The following example uses ``dtype_backend="numpy_nullable"`` 636s 636s >>> data = '''{{"index": {{"0": 0, "1": 1}}, 636s ... "a": {{"0": 1, "1": null}}, 636s ... "b": {{"0": 2.5, "1": 4.5}}, 636s ... "c": {{"0": true, "1": false}}, 636s ... "d": {{"0": "a", "1": "b"}}, 636s ... "e": {{"0": 1577.2, "1": 1577.1}}}}''' 636s >>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable") 636s index a b c d e 636s 0 0 1 2.5 True a 1577.2 636s 1 1 4.5 False b 1577.1 636s """ 636s if orient == "table" and dtype: 636s raise ValueError("cannot pass both dtype and orient='table'") 636s if orient == "table" and convert_axes: 636s raise ValueError("cannot pass both convert_axes and orient='table'") 636s 636s check_dtype_backend(dtype_backend) 636s 636s if dtype is None and orient != "table": 636s # error: Incompatible types in assignment (expression has type "bool", variable 636s # has type "Union[ExtensionDtype, str, dtype[Any], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object], Dict[Hashable, 636s # Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object]]], None]") 636s dtype = True # type: ignore[assignment] 636s if convert_axes is None and orient != "table": 636s convert_axes = True 636s 636s > json_reader = JsonReader( 636s path_or_buf, 636s orient=orient, 636s typ=typ, 636s dtype=dtype, 636s convert_axes=convert_axes, 636s convert_dates=convert_dates, 636s keep_default_dates=keep_default_dates, 636s precise_float=precise_float, 636s date_unit=date_unit, 636s encoding=encoding, 636s lines=lines, 636s chunksize=chunksize, 636s compression=compression, 636s nrows=nrows, 636s storage_options=storage_options, 636s encoding_errors=encoding_errors, 636s dtype_backend=dtype_backend, 636s engine=engine, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:791: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:34401', orient = None, typ = 'frame' 636s dtype = True, convert_axes = True, convert_dates = True 636s keep_default_dates = True, precise_float = False, date_unit = None 636s encoding = None, lines = False, chunksize = None, compression = 'infer' 636s nrows = None, storage_options = {'User-Agent': 'foo'} 636s encoding_errors = 'strict', dtype_backend = , engine = 'ujson' 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s orient, 636s typ: FrameSeriesStrT, 636s dtype, 636s convert_axes: bool | None, 636s convert_dates, 636s keep_default_dates: bool, 636s precise_float: bool, 636s date_unit, 636s encoding, 636s lines: bool, 636s chunksize: int | None, 636s compression: CompressionOptions, 636s nrows: int | None, 636s storage_options: StorageOptions | None = None, 636s encoding_errors: str | None = "strict", 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> None: 636s self.orient = orient 636s self.typ = typ 636s self.dtype = dtype 636s self.convert_axes = convert_axes 636s self.convert_dates = convert_dates 636s self.keep_default_dates = keep_default_dates 636s self.precise_float = precise_float 636s self.date_unit = date_unit 636s self.encoding = encoding 636s self.engine = engine 636s self.compression = compression 636s self.storage_options = storage_options 636s self.lines = lines 636s self.chunksize = chunksize 636s self.nrows_seen = 0 636s self.nrows = nrows 636s self.encoding_errors = encoding_errors 636s self.handles: IOHandles[str] | None = None 636s self.dtype_backend = dtype_backend 636s 636s if self.engine not in {"pyarrow", "ujson"}: 636s raise ValueError( 636s f"The engine type {self.engine} is currently not supported." 636s ) 636s if self.chunksize is not None: 636s self.chunksize = validate_integer("chunksize", self.chunksize, 1) 636s if not self.lines: 636s raise ValueError("chunksize can only be passed if lines=True") 636s if self.engine == "pyarrow": 636s raise ValueError( 636s "currently pyarrow engine doesn't support chunksize parameter" 636s ) 636s if self.nrows is not None: 636s self.nrows = validate_integer("nrows", self.nrows, 0) 636s if not self.lines: 636s raise ValueError("nrows can only be passed if lines=True") 636s if ( 636s isinstance(filepath_or_buffer, str) 636s and not self.lines 636s and "\n" in filepath_or_buffer 636s ): 636s warnings.warn( 636s "Passing literal json to 'read_json' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s if self.engine == "pyarrow": 636s if not self.lines: 636s raise ValueError( 636s "currently pyarrow engine only supports " 636s "the line-delimited JSON format" 636s ) 636s self.data = filepath_or_buffer 636s elif self.engine == "ujson": 636s > data = self._get_data_from_filepath(filepath_or_buffer) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:904: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:34401' 636s 636s def _get_data_from_filepath(self, filepath_or_buffer): 636s """ 636s The function read_json accepts three input types: 636s 1. filepath (string-like) 636s 2. file-like object (e.g. open file object, StringIO) 636s 3. JSON string 636s 636s This method turns (1) into (2) to simplify the rest of the processing. 636s It returns input types (2) and (3) unchanged. 636s 636s It raises FileNotFoundError if the input is a string ending in 636s one of .json, .json.gz, .json.bz2, etc. but no such file exists. 636s """ 636s # if it is a string but the file does not exist, it might be a JSON string 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s if ( 636s not isinstance(filepath_or_buffer, str) 636s or is_url(filepath_or_buffer) 636s or is_fsspec_url(filepath_or_buffer) 636s or file_exists(filepath_or_buffer) 636s ): 636s > self.handles = get_handle( 636s filepath_or_buffer, 636s "r", 636s encoding=self.encoding, 636s compression=self.compression, 636s storage_options=self.storage_options, 636s errors=self.encoding_errors, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:944: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:34401', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:34401', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r' 636s storage_options = {'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ________ test_request_headers[storage_options1-html_responder-] ________ 636s 636s responder = 636s read_method = at 0x7963fd5ca980> 636s httpserver = , started 133469804762816)> 636s storage_options = {'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = ('http://127.0.0.1:38949',) 636s kwargs = {'storage_options': {'User-Agent': 'foo'}} 636s 636s > lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:93: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:38949' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('lxml', 'bs4'), io = 'http://127.0.0.1:38949', match = '.+' 636s attrs = None, encoding = None, displayed_only = True, extract_links = None 636s storage_options = {'User-Agent': 'foo'} 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('.+'), retained = None, flav = 'lxml' 636s parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s r = parse(f.handle, parser=parser) 636s else: 636s # try to parse the input in the simplest way 636s r = parse(self.io, parser=parser) 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s except (UnicodeDecodeError, OSError) as e: 636s # if the input is a blob of html goop 636s if not is_url(self.io): 636s r = fromstring(self.io, parser=parser) 636s 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s else: 636s > raise e 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:806: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s > with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:785: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:38949', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:38949', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r' 636s storage_options = {'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______ test_request_headers[storage_options1-pickle_respnder-read_pickle] ______ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469821548224)> 636s storage_options = {'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:37661', compression = 'infer' 636s storage_options = {'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "filepath_or_buffer", 636s ) 636s def read_pickle( 636s filepath_or_buffer: FilePath | ReadPickleBuffer, 636s compression: CompressionOptions = "infer", 636s storage_options: StorageOptions | None = None, 636s ) -> DataFrame | Series: 636s """ 636s Load pickled pandas object (or any object) from file. 636s 636s .. warning:: 636s 636s Loading pickled data received from untrusted sources can be 636s unsafe. See `here `__. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a binary ``readlines()`` function. 636s Also accepts URL. URL is not limited to S3 and GCS. 636s 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s {storage_options} 636s 636s Returns 636s ------- 636s same type as object stored in file 636s 636s See Also 636s -------- 636s DataFrame.to_pickle : Pickle (serialize) DataFrame object to file. 636s Series.to_pickle : Pickle (serialize) Series object to file. 636s read_hdf : Read HDF5 file into a DataFrame. 636s read_sql : Read SQL query or database table into a DataFrame. 636s read_parquet : Load a parquet object, returning a DataFrame. 636s 636s Notes 636s ----- 636s read_pickle is only guaranteed to be backwards compatible to pandas 0.20.3 636s provided the object was serialized with to_pickle. 636s 636s Examples 636s -------- 636s >>> original_df = pd.DataFrame( 636s ... {{"foo": range(5), "bar": range(5, 10)}} 636s ... ) # doctest: +SKIP 636s >>> original_df # doctest: +SKIP 636s foo bar 636s 0 0 5 636s 1 1 6 636s 2 2 7 636s 3 3 8 636s 4 4 9 636s >>> pd.to_pickle(original_df, "./dummy.pkl") # doctest: +SKIP 636s 636s >>> unpickled_df = pd.read_pickle("./dummy.pkl") # doctest: +SKIP 636s >>> unpickled_df # doctest: +SKIP 636s foo bar 636s 0 0 5 636s 1 1 6 636s 2 2 7 636s 3 3 8 636s 4 4 9 636s """ 636s excs_to_catch = (AttributeError, ImportError, ModuleNotFoundError, TypeError) 636s > with get_handle( 636s filepath_or_buffer, 636s "rb", 636s compression=compression, 636s is_text=False, 636s storage_options=storage_options, 636s ) as handles: 636s 636s /usr/lib/python3/dist-packages/pandas/io/pickle.py:185: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:37661', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:37661', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb' 636s storage_options = {'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______ test_request_headers[storage_options1-stata_responder-read_stata] _______ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469846726336)> 636s storage_options = {'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39117' 636s 636s @Appender(_read_stata_doc) 636s def read_stata( 636s filepath_or_buffer: FilePath | ReadBuffer[bytes], 636s *, 636s convert_dates: bool = True, 636s convert_categoricals: bool = True, 636s index_col: str | None = None, 636s convert_missing: bool = False, 636s preserve_dtypes: bool = True, 636s columns: Sequence[str] | None = None, 636s order_categoricals: bool = True, 636s chunksize: int | None = None, 636s iterator: bool = False, 636s compression: CompressionOptions = "infer", 636s storage_options: StorageOptions | None = None, 636s ) -> DataFrame | StataReader: 636s reader = StataReader( 636s filepath_or_buffer, 636s convert_dates=convert_dates, 636s convert_categoricals=convert_categoricals, 636s index_col=index_col, 636s convert_missing=convert_missing, 636s preserve_dtypes=preserve_dtypes, 636s columns=columns, 636s order_categoricals=order_categoricals, 636s chunksize=chunksize, 636s storage_options=storage_options, 636s compression=compression, 636s ) 636s 636s if iterator or chunksize: 636s return reader 636s 636s with reader: 636s > return reader.read() 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:2113: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , nrows = None 636s convert_dates = None, convert_categoricals = None, index_col = None 636s convert_missing = None, preserve_dtypes = None, columns = None 636s order_categoricals = None 636s 636s @Appender(_read_method_doc) 636s def read( 636s self, 636s nrows: int | None = None, 636s convert_dates: bool | None = None, 636s convert_categoricals: bool | None = None, 636s index_col: str | None = None, 636s convert_missing: bool | None = None, 636s preserve_dtypes: bool | None = None, 636s columns: Sequence[str] | None = None, 636s order_categoricals: bool | None = None, 636s ) -> DataFrame: 636s > self._ensure_open() 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:1687: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _ensure_open(self) -> None: 636s """ 636s Ensure the file has been opened and its header data read. 636s """ 636s if not hasattr(self, "_path_or_buf"): 636s > self._open_file() 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:1179: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _open_file(self) -> None: 636s """ 636s Open the file (with compression options, etc.), and read header information. 636s """ 636s if not self._entered: 636s warnings.warn( 636s "StataReader is being used without using a context manager. " 636s "Using StataReader as a context manager is the only supported method.", 636s ResourceWarning, 636s stacklevel=find_stack_level(), 636s ) 636s > handles = get_handle( 636s self._original_path_or_buf, 636s "rb", 636s storage_options=self._storage_options, 636s is_text=False, 636s compression=self._compression, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:1192: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:39117', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:39117', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb' 636s storage_options = {'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______ test_request_headers[storage_options1-gz_csv_responder-read_csv] _______ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469838333632)> 636s storage_options = {'Content-Encoding': 'gzip', 'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45691' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45691' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:45691', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:45691', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:45691', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45691', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r' 636s storage_options = {'Content-Encoding': 'gzip', 'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______ test_request_headers[storage_options1-gz_json_responder-read_json] ______ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469796370112)> 636s storage_options = {'Content-Encoding': 'gzip', 'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:46121' 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "path_or_buf", 636s ) 636s def read_json( 636s path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], 636s *, 636s orient: str | None = None, 636s typ: Literal["frame", "series"] = "frame", 636s dtype: DtypeArg | None = None, 636s convert_axes: bool | None = None, 636s convert_dates: bool | list[str] = True, 636s keep_default_dates: bool = True, 636s precise_float: bool = False, 636s date_unit: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s lines: bool = False, 636s chunksize: int | None = None, 636s compression: CompressionOptions = "infer", 636s nrows: int | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> DataFrame | Series | JsonReader: 636s """ 636s Convert a JSON string to pandas object. 636s 636s Parameters 636s ---------- 636s path_or_buf : a valid JSON str, path object or file-like object 636s Any valid string path is acceptable. The string could be a URL. Valid 636s URL schemes include http, ftp, s3, and file. For file URLs, a host is 636s expected. A local file could be: 636s ``file://localhost/path/to/table.json``. 636s 636s If you want to pass in a path object, pandas accepts any 636s ``os.PathLike``. 636s 636s By file-like object, we refer to objects with a ``read()`` method, 636s such as a file handle (e.g. via builtin ``open`` function) 636s or ``StringIO``. 636s 636s .. deprecated:: 2.1.0 636s Passing json literal strings is deprecated. 636s 636s orient : str, optional 636s Indication of expected JSON string format. 636s Compatible JSON strings can be produced by ``to_json()`` with a 636s corresponding orient value. 636s The set of possible orients is: 636s 636s - ``'split'`` : dict like 636s ``{{index -> [index], columns -> [columns], data -> [values]}}`` 636s - ``'records'`` : list like 636s ``[{{column -> value}}, ... , {{column -> value}}]`` 636s - ``'index'`` : dict like ``{{index -> {{column -> value}}}}`` 636s - ``'columns'`` : dict like ``{{column -> {{index -> value}}}}`` 636s - ``'values'`` : just the values array 636s - ``'table'`` : dict like ``{{'schema': {{schema}}, 'data': {{data}}}}`` 636s 636s The allowed and default values depend on the value 636s of the `typ` parameter. 636s 636s * when ``typ == 'series'``, 636s 636s - allowed orients are ``{{'split','records','index'}}`` 636s - default is ``'index'`` 636s - The Series index must be unique for orient ``'index'``. 636s 636s * when ``typ == 'frame'``, 636s 636s - allowed orients are ``{{'split','records','index', 636s 'columns','values', 'table'}}`` 636s - default is ``'columns'`` 636s - The DataFrame index must be unique for orients ``'index'`` and 636s ``'columns'``. 636s - The DataFrame columns must be unique for orients ``'index'``, 636s ``'columns'``, and ``'records'``. 636s 636s typ : {{'frame', 'series'}}, default 'frame' 636s The type of object to recover. 636s 636s dtype : bool or dict, default None 636s If True, infer dtypes; if a dict of column to dtype, then use those; 636s if False, then don't infer dtypes at all, applies only to the data. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_axes : bool, default None 636s Try to convert the axes to the proper dtypes. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_dates : bool or list of str, default True 636s If True then default datelike columns may be converted (depending on 636s keep_default_dates). 636s If False, no dates will be converted. 636s If a list of column names, then those columns will be converted and 636s default datelike columns may also be converted (depending on 636s keep_default_dates). 636s 636s keep_default_dates : bool, default True 636s If parsing dates (convert_dates is not False), then try to parse the 636s default datelike columns. 636s A column label is datelike if 636s 636s * it ends with ``'_at'``, 636s 636s * it ends with ``'_time'``, 636s 636s * it begins with ``'timestamp'``, 636s 636s * it is ``'modified'``, or 636s 636s * it is ``'date'``. 636s 636s precise_float : bool, default False 636s Set to enable usage of higher precision (strtod) function when 636s decoding string to double values. Default (False) is to use fast but 636s less precise builtin functionality. 636s 636s date_unit : str, default None 636s The timestamp unit to detect if converting dates. The default behaviour 636s is to try and detect the correct precision, but if this is not desired 636s then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds, 636s milliseconds, microseconds or nanoseconds respectively. 636s 636s encoding : str, default is 'utf-8' 636s The encoding to use to decode py3 bytes. 636s 636s encoding_errors : str, optional, default "strict" 636s How encoding errors are treated. `List of possible values 636s `_ . 636s 636s .. versionadded:: 1.3.0 636s 636s lines : bool, default False 636s Read the file as a json object per line. 636s 636s chunksize : int, optional 636s Return JsonReader object for iteration. 636s See the `line-delimited json docs 636s `_ 636s for more information on ``chunksize``. 636s This can only be passed if `lines=True`. 636s If this is None, the file will be read into memory all at once. 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s nrows : int, optional 636s The number of lines from the line-delimited jsonfile that has to be read. 636s This can only be passed if `lines=True`. 636s If this is None, all the rows will be returned. 636s 636s {storage_options} 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s engine : {{"ujson", "pyarrow"}}, default "ujson" 636s Parser engine to use. The ``"pyarrow"`` engine is only available when 636s ``lines=True``. 636s 636s .. versionadded:: 2.0 636s 636s Returns 636s ------- 636s Series, DataFrame, or pandas.api.typing.JsonReader 636s A JsonReader is returned when ``chunksize`` is not ``0`` or ``None``. 636s Otherwise, the type returned depends on the value of ``typ``. 636s 636s See Also 636s -------- 636s DataFrame.to_json : Convert a DataFrame to a JSON string. 636s Series.to_json : Convert a Series to a JSON string. 636s json_normalize : Normalize semi-structured JSON data into a flat table. 636s 636s Notes 636s ----- 636s Specific to ``orient='table'``, if a :class:`DataFrame` with a literal 636s :class:`Index` name of `index` gets written with :func:`to_json`, the 636s subsequent read operation will incorrectly set the :class:`Index` name to 636s ``None``. This is because `index` is also used by :func:`DataFrame.to_json` 636s to denote a missing :class:`Index` name, and the subsequent 636s :func:`read_json` operation cannot distinguish between the two. The same 636s limitation is encountered with a :class:`MultiIndex` and any names 636s beginning with ``'level_'``. 636s 636s Examples 636s -------- 636s >>> from io import StringIO 636s >>> df = pd.DataFrame([['a', 'b'], ['c', 'd']], 636s ... index=['row 1', 'row 2'], 636s ... columns=['col 1', 'col 2']) 636s 636s Encoding/decoding a Dataframe using ``'split'`` formatted JSON: 636s 636s >>> df.to_json(orient='split') 636s '\ 636s {{\ 636s "columns":["col 1","col 2"],\ 636s "index":["row 1","row 2"],\ 636s "data":[["a","b"],["c","d"]]\ 636s }}\ 636s ' 636s >>> pd.read_json(StringIO(_), orient='split') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'index'`` formatted JSON: 636s 636s >>> df.to_json(orient='index') 636s '{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}' 636s 636s >>> pd.read_json(StringIO(_), orient='index') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'records'`` formatted JSON. 636s Note that index labels are not preserved with this encoding. 636s 636s >>> df.to_json(orient='records') 636s '[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]' 636s >>> pd.read_json(StringIO(_), orient='records') 636s col 1 col 2 636s 0 a b 636s 1 c d 636s 636s Encoding with Table Schema 636s 636s >>> df.to_json(orient='table') 636s '\ 636s {{"schema":{{"fields":[\ 636s {{"name":"index","type":"string"}},\ 636s {{"name":"col 1","type":"string"}},\ 636s {{"name":"col 2","type":"string"}}],\ 636s "primaryKey":["index"],\ 636s "pandas_version":"1.4.0"}},\ 636s "data":[\ 636s {{"index":"row 1","col 1":"a","col 2":"b"}},\ 636s {{"index":"row 2","col 1":"c","col 2":"d"}}]\ 636s }}\ 636s ' 636s 636s The following example uses ``dtype_backend="numpy_nullable"`` 636s 636s >>> data = '''{{"index": {{"0": 0, "1": 1}}, 636s ... "a": {{"0": 1, "1": null}}, 636s ... "b": {{"0": 2.5, "1": 4.5}}, 636s ... "c": {{"0": true, "1": false}}, 636s ... "d": {{"0": "a", "1": "b"}}, 636s ... "e": {{"0": 1577.2, "1": 1577.1}}}}''' 636s >>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable") 636s index a b c d e 636s 0 0 1 2.5 True a 1577.2 636s 1 1 4.5 False b 1577.1 636s """ 636s if orient == "table" and dtype: 636s raise ValueError("cannot pass both dtype and orient='table'") 636s if orient == "table" and convert_axes: 636s raise ValueError("cannot pass both convert_axes and orient='table'") 636s 636s check_dtype_backend(dtype_backend) 636s 636s if dtype is None and orient != "table": 636s # error: Incompatible types in assignment (expression has type "bool", variable 636s # has type "Union[ExtensionDtype, str, dtype[Any], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object], Dict[Hashable, 636s # Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object]]], None]") 636s dtype = True # type: ignore[assignment] 636s if convert_axes is None and orient != "table": 636s convert_axes = True 636s 636s > json_reader = JsonReader( 636s path_or_buf, 636s orient=orient, 636s typ=typ, 636s dtype=dtype, 636s convert_axes=convert_axes, 636s convert_dates=convert_dates, 636s keep_default_dates=keep_default_dates, 636s precise_float=precise_float, 636s date_unit=date_unit, 636s encoding=encoding, 636s lines=lines, 636s chunksize=chunksize, 636s compression=compression, 636s nrows=nrows, 636s storage_options=storage_options, 636s encoding_errors=encoding_errors, 636s dtype_backend=dtype_backend, 636s engine=engine, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:791: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:46121', orient = None, typ = 'frame' 636s dtype = True, convert_axes = True, convert_dates = True 636s keep_default_dates = True, precise_float = False, date_unit = None 636s encoding = None, lines = False, chunksize = None, compression = 'infer' 636s nrows = None 636s storage_options = {'Content-Encoding': 'gzip', 'User-Agent': 'foo'} 636s encoding_errors = 'strict', dtype_backend = , engine = 'ujson' 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s orient, 636s typ: FrameSeriesStrT, 636s dtype, 636s convert_axes: bool | None, 636s convert_dates, 636s keep_default_dates: bool, 636s precise_float: bool, 636s date_unit, 636s encoding, 636s lines: bool, 636s chunksize: int | None, 636s compression: CompressionOptions, 636s nrows: int | None, 636s storage_options: StorageOptions | None = None, 636s encoding_errors: str | None = "strict", 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> None: 636s self.orient = orient 636s self.typ = typ 636s self.dtype = dtype 636s self.convert_axes = convert_axes 636s self.convert_dates = convert_dates 636s self.keep_default_dates = keep_default_dates 636s self.precise_float = precise_float 636s self.date_unit = date_unit 636s self.encoding = encoding 636s self.engine = engine 636s self.compression = compression 636s self.storage_options = storage_options 636s self.lines = lines 636s self.chunksize = chunksize 636s self.nrows_seen = 0 636s self.nrows = nrows 636s self.encoding_errors = encoding_errors 636s self.handles: IOHandles[str] | None = None 636s self.dtype_backend = dtype_backend 636s 636s if self.engine not in {"pyarrow", "ujson"}: 636s raise ValueError( 636s f"The engine type {self.engine} is currently not supported." 636s ) 636s if self.chunksize is not None: 636s self.chunksize = validate_integer("chunksize", self.chunksize, 1) 636s if not self.lines: 636s raise ValueError("chunksize can only be passed if lines=True") 636s if self.engine == "pyarrow": 636s raise ValueError( 636s "currently pyarrow engine doesn't support chunksize parameter" 636s ) 636s if self.nrows is not None: 636s self.nrows = validate_integer("nrows", self.nrows, 0) 636s if not self.lines: 636s raise ValueError("nrows can only be passed if lines=True") 636s if ( 636s isinstance(filepath_or_buffer, str) 636s and not self.lines 636s and "\n" in filepath_or_buffer 636s ): 636s warnings.warn( 636s "Passing literal json to 'read_json' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s if self.engine == "pyarrow": 636s if not self.lines: 636s raise ValueError( 636s "currently pyarrow engine only supports " 636s "the line-delimited JSON format" 636s ) 636s self.data = filepath_or_buffer 636s elif self.engine == "ujson": 636s > data = self._get_data_from_filepath(filepath_or_buffer) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:904: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:46121' 636s 636s def _get_data_from_filepath(self, filepath_or_buffer): 636s """ 636s The function read_json accepts three input types: 636s 1. filepath (string-like) 636s 2. file-like object (e.g. open file object, StringIO) 636s 3. JSON string 636s 636s This method turns (1) into (2) to simplify the rest of the processing. 636s It returns input types (2) and (3) unchanged. 636s 636s It raises FileNotFoundError if the input is a string ending in 636s one of .json, .json.gz, .json.bz2, etc. but no such file exists. 636s """ 636s # if it is a string but the file does not exist, it might be a JSON string 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s if ( 636s not isinstance(filepath_or_buffer, str) 636s or is_url(filepath_or_buffer) 636s or is_fsspec_url(filepath_or_buffer) 636s or file_exists(filepath_or_buffer) 636s ): 636s > self.handles = get_handle( 636s filepath_or_buffer, 636s "r", 636s encoding=self.encoding, 636s compression=self.compression, 636s storage_options=self.storage_options, 636s errors=self.encoding_errors, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:944: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:46121', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:46121', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r' 636s storage_options = {'Content-Encoding': 'gzip', 'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ________ test_request_headers[storage_options2-csv_responder-read_csv] _________ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469838333632)> 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:36043' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:36043' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:36043', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:36043', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:36043', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:36043', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r' 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______ test_request_headers[storage_options2-json_responder-read_json] ________ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469846726336)> 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:35009' 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "path_or_buf", 636s ) 636s def read_json( 636s path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], 636s *, 636s orient: str | None = None, 636s typ: Literal["frame", "series"] = "frame", 636s dtype: DtypeArg | None = None, 636s convert_axes: bool | None = None, 636s convert_dates: bool | list[str] = True, 636s keep_default_dates: bool = True, 636s precise_float: bool = False, 636s date_unit: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s lines: bool = False, 636s chunksize: int | None = None, 636s compression: CompressionOptions = "infer", 636s nrows: int | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> DataFrame | Series | JsonReader: 636s """ 636s Convert a JSON string to pandas object. 636s 636s Parameters 636s ---------- 636s path_or_buf : a valid JSON str, path object or file-like object 636s Any valid string path is acceptable. The string could be a URL. Valid 636s URL schemes include http, ftp, s3, and file. For file URLs, a host is 636s expected. A local file could be: 636s ``file://localhost/path/to/table.json``. 636s 636s If you want to pass in a path object, pandas accepts any 636s ``os.PathLike``. 636s 636s By file-like object, we refer to objects with a ``read()`` method, 636s such as a file handle (e.g. via builtin ``open`` function) 636s or ``StringIO``. 636s 636s .. deprecated:: 2.1.0 636s Passing json literal strings is deprecated. 636s 636s orient : str, optional 636s Indication of expected JSON string format. 636s Compatible JSON strings can be produced by ``to_json()`` with a 636s corresponding orient value. 636s The set of possible orients is: 636s 636s - ``'split'`` : dict like 636s ``{{index -> [index], columns -> [columns], data -> [values]}}`` 636s - ``'records'`` : list like 636s ``[{{column -> value}}, ... , {{column -> value}}]`` 636s - ``'index'`` : dict like ``{{index -> {{column -> value}}}}`` 636s - ``'columns'`` : dict like ``{{column -> {{index -> value}}}}`` 636s - ``'values'`` : just the values array 636s - ``'table'`` : dict like ``{{'schema': {{schema}}, 'data': {{data}}}}`` 636s 636s The allowed and default values depend on the value 636s of the `typ` parameter. 636s 636s * when ``typ == 'series'``, 636s 636s - allowed orients are ``{{'split','records','index'}}`` 636s - default is ``'index'`` 636s - The Series index must be unique for orient ``'index'``. 636s 636s * when ``typ == 'frame'``, 636s 636s - allowed orients are ``{{'split','records','index', 636s 'columns','values', 'table'}}`` 636s - default is ``'columns'`` 636s - The DataFrame index must be unique for orients ``'index'`` and 636s ``'columns'``. 636s - The DataFrame columns must be unique for orients ``'index'``, 636s ``'columns'``, and ``'records'``. 636s 636s typ : {{'frame', 'series'}}, default 'frame' 636s The type of object to recover. 636s 636s dtype : bool or dict, default None 636s If True, infer dtypes; if a dict of column to dtype, then use those; 636s if False, then don't infer dtypes at all, applies only to the data. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_axes : bool, default None 636s Try to convert the axes to the proper dtypes. 636s 636s For all ``orient`` values except ``'table'``, default is True. 636s 636s convert_dates : bool or list of str, default True 636s If True then default datelike columns may be converted (depending on 636s keep_default_dates). 636s If False, no dates will be converted. 636s If a list of column names, then those columns will be converted and 636s default datelike columns may also be converted (depending on 636s keep_default_dates). 636s 636s keep_default_dates : bool, default True 636s If parsing dates (convert_dates is not False), then try to parse the 636s default datelike columns. 636s A column label is datelike if 636s 636s * it ends with ``'_at'``, 636s 636s * it ends with ``'_time'``, 636s 636s * it begins with ``'timestamp'``, 636s 636s * it is ``'modified'``, or 636s 636s * it is ``'date'``. 636s 636s precise_float : bool, default False 636s Set to enable usage of higher precision (strtod) function when 636s decoding string to double values. Default (False) is to use fast but 636s less precise builtin functionality. 636s 636s date_unit : str, default None 636s The timestamp unit to detect if converting dates. The default behaviour 636s is to try and detect the correct precision, but if this is not desired 636s then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds, 636s milliseconds, microseconds or nanoseconds respectively. 636s 636s encoding : str, default is 'utf-8' 636s The encoding to use to decode py3 bytes. 636s 636s encoding_errors : str, optional, default "strict" 636s How encoding errors are treated. `List of possible values 636s `_ . 636s 636s .. versionadded:: 1.3.0 636s 636s lines : bool, default False 636s Read the file as a json object per line. 636s 636s chunksize : int, optional 636s Return JsonReader object for iteration. 636s See the `line-delimited json docs 636s `_ 636s for more information on ``chunksize``. 636s This can only be passed if `lines=True`. 636s If this is None, the file will be read into memory all at once. 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s nrows : int, optional 636s The number of lines from the line-delimited jsonfile that has to be read. 636s This can only be passed if `lines=True`. 636s If this is None, all the rows will be returned. 636s 636s {storage_options} 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s engine : {{"ujson", "pyarrow"}}, default "ujson" 636s Parser engine to use. The ``"pyarrow"`` engine is only available when 636s ``lines=True``. 636s 636s .. versionadded:: 2.0 636s 636s Returns 636s ------- 636s Series, DataFrame, or pandas.api.typing.JsonReader 636s A JsonReader is returned when ``chunksize`` is not ``0`` or ``None``. 636s Otherwise, the type returned depends on the value of ``typ``. 636s 636s See Also 636s -------- 636s DataFrame.to_json : Convert a DataFrame to a JSON string. 636s Series.to_json : Convert a Series to a JSON string. 636s json_normalize : Normalize semi-structured JSON data into a flat table. 636s 636s Notes 636s ----- 636s Specific to ``orient='table'``, if a :class:`DataFrame` with a literal 636s :class:`Index` name of `index` gets written with :func:`to_json`, the 636s subsequent read operation will incorrectly set the :class:`Index` name to 636s ``None``. This is because `index` is also used by :func:`DataFrame.to_json` 636s to denote a missing :class:`Index` name, and the subsequent 636s :func:`read_json` operation cannot distinguish between the two. The same 636s limitation is encountered with a :class:`MultiIndex` and any names 636s beginning with ``'level_'``. 636s 636s Examples 636s -------- 636s >>> from io import StringIO 636s >>> df = pd.DataFrame([['a', 'b'], ['c', 'd']], 636s ... index=['row 1', 'row 2'], 636s ... columns=['col 1', 'col 2']) 636s 636s Encoding/decoding a Dataframe using ``'split'`` formatted JSON: 636s 636s >>> df.to_json(orient='split') 636s '\ 636s {{\ 636s "columns":["col 1","col 2"],\ 636s "index":["row 1","row 2"],\ 636s "data":[["a","b"],["c","d"]]\ 636s }}\ 636s ' 636s >>> pd.read_json(StringIO(_), orient='split') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'index'`` formatted JSON: 636s 636s >>> df.to_json(orient='index') 636s '{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}' 636s 636s >>> pd.read_json(StringIO(_), orient='index') 636s col 1 col 2 636s row 1 a b 636s row 2 c d 636s 636s Encoding/decoding a Dataframe using ``'records'`` formatted JSON. 636s Note that index labels are not preserved with this encoding. 636s 636s >>> df.to_json(orient='records') 636s '[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]' 636s >>> pd.read_json(StringIO(_), orient='records') 636s col 1 col 2 636s 0 a b 636s 1 c d 636s 636s Encoding with Table Schema 636s 636s >>> df.to_json(orient='table') 636s '\ 636s {{"schema":{{"fields":[\ 636s {{"name":"index","type":"string"}},\ 636s {{"name":"col 1","type":"string"}},\ 636s {{"name":"col 2","type":"string"}}],\ 636s "primaryKey":["index"],\ 636s "pandas_version":"1.4.0"}},\ 636s "data":[\ 636s {{"index":"row 1","col 1":"a","col 2":"b"}},\ 636s {{"index":"row 2","col 1":"c","col 2":"d"}}]\ 636s }}\ 636s ' 636s 636s The following example uses ``dtype_backend="numpy_nullable"`` 636s 636s >>> data = '''{{"index": {{"0": 0, "1": 1}}, 636s ... "a": {{"0": 1, "1": null}}, 636s ... "b": {{"0": 2.5, "1": 4.5}}, 636s ... "c": {{"0": true, "1": false}}, 636s ... "d": {{"0": "a", "1": "b"}}, 636s ... "e": {{"0": 1577.2, "1": 1577.1}}}}''' 636s >>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable") 636s index a b c d e 636s 0 0 1 2.5 True a 1577.2 636s 1 1 4.5 False b 1577.1 636s """ 636s if orient == "table" and dtype: 636s raise ValueError("cannot pass both dtype and orient='table'") 636s if orient == "table" and convert_axes: 636s raise ValueError("cannot pass both convert_axes and orient='table'") 636s 636s check_dtype_backend(dtype_backend) 636s 636s if dtype is None and orient != "table": 636s # error: Incompatible types in assignment (expression has type "bool", variable 636s # has type "Union[ExtensionDtype, str, dtype[Any], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object], Dict[Hashable, 636s # Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float], 636s # Type[int], Type[complex], Type[bool], Type[object]]], None]") 636s dtype = True # type: ignore[assignment] 636s if convert_axes is None and orient != "table": 636s convert_axes = True 636s 636s > json_reader = JsonReader( 636s path_or_buf, 636s orient=orient, 636s typ=typ, 636s dtype=dtype, 636s convert_axes=convert_axes, 636s convert_dates=convert_dates, 636s keep_default_dates=keep_default_dates, 636s precise_float=precise_float, 636s date_unit=date_unit, 636s encoding=encoding, 636s lines=lines, 636s chunksize=chunksize, 636s compression=compression, 636s nrows=nrows, 636s storage_options=storage_options, 636s encoding_errors=encoding_errors, 636s dtype_backend=dtype_backend, 636s engine=engine, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:791: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:35009', orient = None, typ = 'frame' 636s dtype = True, convert_axes = True, convert_dates = True 636s keep_default_dates = True, precise_float = False, date_unit = None 636s encoding = None, lines = False, chunksize = None, compression = 'infer' 636s nrows = None, storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s encoding_errors = 'strict', dtype_backend = , engine = 'ujson' 636s 636s def __init__( 636s self, 636s filepath_or_buffer, 636s orient, 636s typ: FrameSeriesStrT, 636s dtype, 636s convert_axes: bool | None, 636s convert_dates, 636s keep_default_dates: bool, 636s precise_float: bool, 636s date_unit, 636s encoding, 636s lines: bool, 636s chunksize: int | None, 636s compression: CompressionOptions, 636s nrows: int | None, 636s storage_options: StorageOptions | None = None, 636s encoding_errors: str | None = "strict", 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s engine: JSONEngine = "ujson", 636s ) -> None: 636s self.orient = orient 636s self.typ = typ 636s self.dtype = dtype 636s self.convert_axes = convert_axes 636s self.convert_dates = convert_dates 636s self.keep_default_dates = keep_default_dates 636s self.precise_float = precise_float 636s self.date_unit = date_unit 636s self.encoding = encoding 636s self.engine = engine 636s self.compression = compression 636s self.storage_options = storage_options 636s self.lines = lines 636s self.chunksize = chunksize 636s self.nrows_seen = 0 636s self.nrows = nrows 636s self.encoding_errors = encoding_errors 636s self.handles: IOHandles[str] | None = None 636s self.dtype_backend = dtype_backend 636s 636s if self.engine not in {"pyarrow", "ujson"}: 636s raise ValueError( 636s f"The engine type {self.engine} is currently not supported." 636s ) 636s if self.chunksize is not None: 636s self.chunksize = validate_integer("chunksize", self.chunksize, 1) 636s if not self.lines: 636s raise ValueError("chunksize can only be passed if lines=True") 636s if self.engine == "pyarrow": 636s raise ValueError( 636s "currently pyarrow engine doesn't support chunksize parameter" 636s ) 636s if self.nrows is not None: 636s self.nrows = validate_integer("nrows", self.nrows, 0) 636s if not self.lines: 636s raise ValueError("nrows can only be passed if lines=True") 636s if ( 636s isinstance(filepath_or_buffer, str) 636s and not self.lines 636s and "\n" in filepath_or_buffer 636s ): 636s warnings.warn( 636s "Passing literal json to 'read_json' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s if self.engine == "pyarrow": 636s if not self.lines: 636s raise ValueError( 636s "currently pyarrow engine only supports " 636s "the line-delimited JSON format" 636s ) 636s self.data = filepath_or_buffer 636s elif self.engine == "ujson": 636s > data = self._get_data_from_filepath(filepath_or_buffer) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:904: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s filepath_or_buffer = 'http://127.0.0.1:35009' 636s 636s def _get_data_from_filepath(self, filepath_or_buffer): 636s """ 636s The function read_json accepts three input types: 636s 1. filepath (string-like) 636s 2. file-like object (e.g. open file object, StringIO) 636s 3. JSON string 636s 636s This method turns (1) into (2) to simplify the rest of the processing. 636s It returns input types (2) and (3) unchanged. 636s 636s It raises FileNotFoundError if the input is a string ending in 636s one of .json, .json.gz, .json.bz2, etc. but no such file exists. 636s """ 636s # if it is a string but the file does not exist, it might be a JSON string 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s if ( 636s not isinstance(filepath_or_buffer, str) 636s or is_url(filepath_or_buffer) 636s or is_fsspec_url(filepath_or_buffer) 636s or file_exists(filepath_or_buffer) 636s ): 636s > self.handles = get_handle( 636s filepath_or_buffer, 636s "r", 636s encoding=self.encoding, 636s compression=self.compression, 636s storage_options=self.storage_options, 636s errors=self.encoding_errors, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:944: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:35009', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:35009', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r' 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ________ test_request_headers[storage_options2-html_responder-] ________ 636s 636s responder = 636s read_method = at 0x7963fd5ca980> 636s httpserver = , started 133469821548224)> 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = ('http://127.0.0.1:42105',) 636s kwargs = {'storage_options': {'Auth': 'bar', 'User-Agent': 'foo'}} 636s 636s > lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:93: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s io = 'http://127.0.0.1:42105' 636s 636s @doc(storage_options=_shared_docs["storage_options"]) 636s def read_html( 636s io: FilePath | ReadBuffer[str], 636s *, 636s match: str | Pattern = ".+", 636s flavor: HTMLFlavors | Sequence[HTMLFlavors] | None = None, 636s header: int | Sequence[int] | None = None, 636s index_col: int | Sequence[int] | None = None, 636s skiprows: int | Sequence[int] | slice | None = None, 636s attrs: dict[str, str] | None = None, 636s parse_dates: bool = False, 636s thousands: str | None = ",", 636s encoding: str | None = None, 636s decimal: str = ".", 636s converters: dict | None = None, 636s na_values: Iterable[object] | None = None, 636s keep_default_na: bool = True, 636s displayed_only: bool = True, 636s extract_links: Literal[None, "header", "footer", "body", "all"] = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s storage_options: StorageOptions = None, 636s ) -> list[DataFrame]: 636s r""" 636s Read HTML tables into a ``list`` of ``DataFrame`` objects. 636s 636s Parameters 636s ---------- 636s io : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a string ``read()`` function. 636s The string can represent a URL or the HTML itself. Note that 636s lxml only accepts the http, ftp and file url protocols. If you have a 636s URL that starts with ``'https'`` you might try removing the ``'s'``. 636s 636s .. deprecated:: 2.1.0 636s Passing html literal strings is deprecated. 636s Wrap literal string/bytes input in ``io.StringIO``/``io.BytesIO`` instead. 636s 636s match : str or compiled regular expression, optional 636s The set of tables containing text matching this regex or string will be 636s returned. Unless the HTML is extremely simple you will probably need to 636s pass a non-empty string here. Defaults to '.+' (match any non-empty 636s string). The default value will return all tables contained on a page. 636s This value is converted to a regular expression so that there is 636s consistent behavior between Beautiful Soup and lxml. 636s 636s flavor : {{"lxml", "html5lib", "bs4"}} or list-like, optional 636s The parsing engine (or list of parsing engines) to use. 'bs4' and 636s 'html5lib' are synonymous with each other, they are both there for 636s backwards compatibility. The default of ``None`` tries to use ``lxml`` 636s to parse and if that fails it falls back on ``bs4`` + ``html5lib``. 636s 636s header : int or list-like, optional 636s The row (or list of rows for a :class:`~pandas.MultiIndex`) to use to 636s make the columns headers. 636s 636s index_col : int or list-like, optional 636s The column (or list of columns) to use to create the index. 636s 636s skiprows : int, list-like or slice, optional 636s Number of rows to skip after parsing the column integer. 0-based. If a 636s sequence of integers or a slice is given, will skip the rows indexed by 636s that sequence. Note that a single element sequence means 'skip the nth 636s row' whereas an integer means 'skip n rows'. 636s 636s attrs : dict, optional 636s This is a dictionary of attributes that you can pass to use to identify 636s the table in the HTML. These are not checked for validity before being 636s passed to lxml or Beautiful Soup. However, these attributes must be 636s valid HTML table attributes to work correctly. For example, :: 636s 636s attrs = {{'id': 'table'}} 636s 636s is a valid attribute dictionary because the 'id' HTML tag attribute is 636s a valid HTML attribute for *any* HTML tag as per `this document 636s `__. :: 636s 636s attrs = {{'asdf': 'table'}} 636s 636s is *not* a valid attribute dictionary because 'asdf' is not a valid 636s HTML attribute even if it is a valid XML attribute. Valid HTML 4.01 636s table attributes can be found `here 636s `__. A 636s working draft of the HTML 5 spec can be found `here 636s `__. It contains the 636s latest information on table attributes for the modern web. 636s 636s parse_dates : bool, optional 636s See :func:`~read_csv` for more details. 636s 636s thousands : str, optional 636s Separator to use to parse thousands. Defaults to ``','``. 636s 636s encoding : str, optional 636s The encoding used to decode the web page. Defaults to ``None``.``None`` 636s preserves the previous encoding behavior, which depends on the 636s underlying parser library (e.g., the parser library will try to use 636s the encoding provided by the document). 636s 636s decimal : str, default '.' 636s Character to recognize as decimal point (e.g. use ',' for European 636s data). 636s 636s converters : dict, default None 636s Dict of functions for converting values in certain columns. Keys can 636s either be integers or column labels, values are functions that take one 636s input argument, the cell (not column) content, and return the 636s transformed content. 636s 636s na_values : iterable, default None 636s Custom NA values. 636s 636s keep_default_na : bool, default True 636s If na_values are specified and keep_default_na is False the default NaN 636s values are overridden, otherwise they're appended to. 636s 636s displayed_only : bool, default True 636s Whether elements with "display: none" should be parsed. 636s 636s extract_links : {{None, "all", "header", "body", "footer"}} 636s Table elements in the specified section(s) with tags will have their 636s href extracted. 636s 636s .. versionadded:: 1.5.0 636s 636s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 636s Back-end data type applied to the resultant :class:`DataFrame` 636s (still experimental). Behaviour is as follows: 636s 636s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 636s (default). 636s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 636s DataFrame. 636s 636s .. versionadded:: 2.0 636s 636s {storage_options} 636s 636s .. versionadded:: 2.1.0 636s 636s Returns 636s ------- 636s dfs 636s A list of DataFrames. 636s 636s See Also 636s -------- 636s read_csv : Read a comma-separated values (csv) file into DataFrame. 636s 636s Notes 636s ----- 636s Before using this function you should read the :ref:`gotchas about the 636s HTML parsing libraries `. 636s 636s Expect to do some cleanup after you call this function. For example, you 636s might need to manually assign column names if the column names are 636s converted to NaN when you pass the `header=0` argument. We try to assume as 636s little as possible about the structure of the table and push the 636s idiosyncrasies of the HTML contained in the table to the user. 636s 636s This function searches for ```` elements and only for ```` 636s and ```` or ```` argument, it is used to construct 636s the header, otherwise the function attempts to find the header within 636s the body (by putting rows with only ``
`` rows and ```` elements within each ``
`` 636s element in the table. ```` stands for "table data". This function 636s attempts to properly handle ``colspan`` and ``rowspan`` attributes. 636s If the function has a ``
`` elements into the header). 636s 636s Similar to :func:`~read_csv` the `header` argument is applied 636s **after** `skiprows` is applied. 636s 636s This function will *always* return a list of :class:`DataFrame` *or* 636s it will fail, e.g., it will *not* return an empty list. 636s 636s Examples 636s -------- 636s See the :ref:`read_html documentation in the IO section of the docs 636s ` for some examples of reading in HTML tables. 636s """ 636s # Type check here. We don't want to parse only to fail because of an 636s # invalid value of an integer skiprows. 636s if isinstance(skiprows, numbers.Integral) and skiprows < 0: 636s raise ValueError( 636s "cannot skip rows starting from the end of the " 636s "data (you passed a negative value)" 636s ) 636s if extract_links not in [None, "header", "footer", "body", "all"]: 636s raise ValueError( 636s "`extract_links` must be one of " 636s '{None, "header", "footer", "body", "all"}, got ' 636s f'"{extract_links}"' 636s ) 636s 636s validate_header_arg(header) 636s check_dtype_backend(dtype_backend) 636s 636s io = stringify_path(io) 636s 636s if isinstance(io, str) and not any( 636s [ 636s is_file_like(io), 636s file_exists(io), 636s is_url(io), 636s is_fsspec_url(io), 636s ] 636s ): 636s warnings.warn( 636s "Passing literal html to 'read_html' is deprecated and " 636s "will be removed in a future version. To read from a " 636s "literal string, wrap it in a 'StringIO' object.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s > return _parse( 636s flavor=flavor, 636s io=io, 636s match=match, 636s header=header, 636s index_col=index_col, 636s skiprows=skiprows, 636s parse_dates=parse_dates, 636s thousands=thousands, 636s attrs=attrs, 636s encoding=encoding, 636s decimal=decimal, 636s converters=converters, 636s na_values=na_values, 636s keep_default_na=keep_default_na, 636s displayed_only=displayed_only, 636s extract_links=extract_links, 636s dtype_backend=dtype_backend, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:1240: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s flavor = ('lxml', 'bs4'), io = 'http://127.0.0.1:42105', match = '.+' 636s attrs = None, encoding = None, displayed_only = True, extract_links = None 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s kwargs = {'converters': None, 'decimal': '.', 'dtype_backend': , 'header': None, ...} 636s compiled_match = re.compile('.+'), retained = None, flav = 'lxml' 636s parser = 636s p = 636s 636s def _parse( 636s flavor, 636s io, 636s match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s **kwargs, 636s ): 636s flavor = _validate_flavor(flavor) 636s compiled_match = re.compile(match) # you can pass a compiled regex here 636s 636s retained = None 636s for flav in flavor: 636s parser = _parser_dispatch(flav) 636s p = parser( 636s io, 636s compiled_match, 636s attrs, 636s encoding, 636s displayed_only, 636s extract_links, 636s storage_options, 636s ) 636s 636s try: 636s > tables = p.parse_tables() 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:983: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def parse_tables(self): 636s """ 636s Parse and return all tables from the DOM. 636s 636s Returns 636s ------- 636s list of parsed (header, body, footer) tuples from tables. 636s """ 636s > tables = self._parse_tables(self._build_doc(), self.match, self.attrs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:249: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s r = parse(f.handle, parser=parser) 636s else: 636s # try to parse the input in the simplest way 636s r = parse(self.io, parser=parser) 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s except (UnicodeDecodeError, OSError) as e: 636s # if the input is a blob of html goop 636s if not is_url(self.io): 636s r = fromstring(self.io, parser=parser) 636s 636s try: 636s r = r.getroot() 636s except AttributeError: 636s pass 636s else: 636s > raise e 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:806: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _build_doc(self): 636s """ 636s Raises 636s ------ 636s ValueError 636s * If a URL that lxml cannot parse is passed. 636s 636s Exception 636s * Any other ``Exception`` thrown. For example, trying to parse a 636s URL that is syntactically correct on a machine with no internet 636s connection will fail. 636s 636s See Also 636s -------- 636s pandas.io.html._HtmlFrameParser._build_doc 636s """ 636s from lxml.etree import XMLSyntaxError 636s from lxml.html import ( 636s HTMLParser, 636s fromstring, 636s parse, 636s ) 636s 636s parser = HTMLParser(recover=True, encoding=self.encoding) 636s 636s try: 636s if is_url(self.io): 636s > with get_handle( 636s self.io, "r", storage_options=self.storage_options 636s ) as f: 636s 636s /usr/lib/python3/dist-packages/pandas/io/html.py:785: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:42105', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:42105', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'r' 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______ test_request_headers[storage_options2-pickle_respnder-read_pickle] ______ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469787977408)> 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45031', compression = 'infer' 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] % "filepath_or_buffer", 636s ) 636s def read_pickle( 636s filepath_or_buffer: FilePath | ReadPickleBuffer, 636s compression: CompressionOptions = "infer", 636s storage_options: StorageOptions | None = None, 636s ) -> DataFrame | Series: 636s """ 636s Load pickled pandas object (or any object) from file. 636s 636s .. warning:: 636s 636s Loading pickled data received from untrusted sources can be 636s unsafe. See `here `__. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : str, path object, or file-like object 636s String, path object (implementing ``os.PathLike[str]``), or file-like 636s object implementing a binary ``readlines()`` function. 636s Also accepts URL. URL is not limited to S3 and GCS. 636s 636s {decompression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s {storage_options} 636s 636s Returns 636s ------- 636s same type as object stored in file 636s 636s See Also 636s -------- 636s DataFrame.to_pickle : Pickle (serialize) DataFrame object to file. 636s Series.to_pickle : Pickle (serialize) Series object to file. 636s read_hdf : Read HDF5 file into a DataFrame. 636s read_sql : Read SQL query or database table into a DataFrame. 636s read_parquet : Load a parquet object, returning a DataFrame. 636s 636s Notes 636s ----- 636s read_pickle is only guaranteed to be backwards compatible to pandas 0.20.3 636s provided the object was serialized with to_pickle. 636s 636s Examples 636s -------- 636s >>> original_df = pd.DataFrame( 636s ... {{"foo": range(5), "bar": range(5, 10)}} 636s ... ) # doctest: +SKIP 636s >>> original_df # doctest: +SKIP 636s foo bar 636s 0 0 5 636s 1 1 6 636s 2 2 7 636s 3 3 8 636s 4 4 9 636s >>> pd.to_pickle(original_df, "./dummy.pkl") # doctest: +SKIP 636s 636s >>> unpickled_df = pd.read_pickle("./dummy.pkl") # doctest: +SKIP 636s >>> unpickled_df # doctest: +SKIP 636s foo bar 636s 0 0 5 636s 1 1 6 636s 2 2 7 636s 3 3 8 636s 4 4 9 636s """ 636s excs_to_catch = (AttributeError, ImportError, ModuleNotFoundError, TypeError) 636s > with get_handle( 636s filepath_or_buffer, 636s "rb", 636s compression=compression, 636s is_text=False, 636s storage_options=storage_options, 636s ) as handles: 636s 636s /usr/lib/python3/dist-packages/pandas/io/pickle.py:185: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:45031', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:45031', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb' 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s ______ test_request_headers[storage_options2-stata_responder-read_stata] _______ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469821548224)> 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43627' 636s 636s @Appender(_read_stata_doc) 636s def read_stata( 636s filepath_or_buffer: FilePath | ReadBuffer[bytes], 636s *, 636s convert_dates: bool = True, 636s convert_categoricals: bool = True, 636s index_col: str | None = None, 636s convert_missing: bool = False, 636s preserve_dtypes: bool = True, 636s columns: Sequence[str] | None = None, 636s order_categoricals: bool = True, 636s chunksize: int | None = None, 636s iterator: bool = False, 636s compression: CompressionOptions = "infer", 636s storage_options: StorageOptions | None = None, 636s ) -> DataFrame | StataReader: 636s reader = StataReader( 636s filepath_or_buffer, 636s convert_dates=convert_dates, 636s convert_categoricals=convert_categoricals, 636s index_col=index_col, 636s convert_missing=convert_missing, 636s preserve_dtypes=preserve_dtypes, 636s columns=columns, 636s order_categoricals=order_categoricals, 636s chunksize=chunksize, 636s storage_options=storage_options, 636s compression=compression, 636s ) 636s 636s if iterator or chunksize: 636s return reader 636s 636s with reader: 636s > return reader.read() 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:2113: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , nrows = None 636s convert_dates = None, convert_categoricals = None, index_col = None 636s convert_missing = None, preserve_dtypes = None, columns = None 636s order_categoricals = None 636s 636s @Appender(_read_method_doc) 636s def read( 636s self, 636s nrows: int | None = None, 636s convert_dates: bool | None = None, 636s convert_categoricals: bool | None = None, 636s index_col: str | None = None, 636s convert_missing: bool | None = None, 636s preserve_dtypes: bool | None = None, 636s columns: Sequence[str] | None = None, 636s order_categoricals: bool | None = None, 636s ) -> DataFrame: 636s > self._ensure_open() 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:1687: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _ensure_open(self) -> None: 636s """ 636s Ensure the file has been opened and its header data read. 636s """ 636s if not hasattr(self, "_path_or_buf"): 636s > self._open_file() 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:1179: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s 636s def _open_file(self) -> None: 636s """ 636s Open the file (with compression options, etc.), and read header information. 636s """ 636s if not self._entered: 636s warnings.warn( 636s "StataReader is being used without using a context manager. " 636s "Using StataReader as a context manager is the only supported method.", 636s ResourceWarning, 636s stacklevel=find_stack_level(), 636s ) 636s > handles = get_handle( 636s self._original_path_or_buf, 636s "rb", 636s storage_options=self._storage_options, 636s is_text=False, 636s compression=self._compression, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/stata.py:1192: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:43627', mode = 'rb' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 636s Passed to _get_filepath_or_buffer 636s 636s Returns the dataclass IOHandles 636s """ 636s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 636s encoding = encoding or "utf-8" 636s 636s errors = errors or "strict" 636s 636s # read_csv does not know whether the buffer is opened in binary/text mode 636s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 636s mode += "b" 636s 636s # validate encoding and errors 636s codecs.lookup(encoding) 636s if isinstance(errors, str): 636s codecs.lookup_error(errors) 636s 636s # open URLs 636s > ioargs = _get_filepath_or_buffer( 636s path_or_buf, 636s encoding=encoding, 636s compression=compression, 636s mode=mode, 636s storage_options=storage_options, 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:43627', encoding = 'utf-8' 636s compression = {'method': None}, mode = 'rb' 636s storage_options = {'Auth': 'bar', 'User-Agent': 'foo'} 636s 636s @doc( 636s storage_options=_shared_docs["storage_options"], 636s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 636s ) 636s def _get_filepath_or_buffer( 636s filepath_or_buffer: FilePath | BaseBuffer, 636s encoding: str = "utf-8", 636s compression: CompressionOptions | None = None, 636s mode: str = "r", 636s storage_options: StorageOptions | None = None, 636s ) -> IOArgs: 636s """ 636s If the filepath_or_buffer is a url, translate and return the buffer. 636s Otherwise passthrough. 636s 636s Parameters 636s ---------- 636s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 636s or buffer 636s {compression_options} 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s encoding : the encoding to use to decode bytes, default is 'utf-8' 636s mode : str, optional 636s 636s {storage_options} 636s 636s 636s Returns the dataclass IOArgs. 636s """ 636s filepath_or_buffer = stringify_path(filepath_or_buffer) 636s 636s # handle compression dict 636s compression_method, compression = get_compression_method(compression) 636s compression_method = infer_compression(filepath_or_buffer, compression_method) 636s 636s # GH21227 internal compression is not used for non-binary handles. 636s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 636s warnings.warn( 636s "compression has no effect when passing a non-binary object as input.", 636s RuntimeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s compression_method = None 636s 636s compression = dict(compression, method=compression_method) 636s 636s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 636s # print a warning when writing such files 636s if ( 636s "w" in mode 636s and compression_method in ["bz2", "xz"] 636s and encoding in ["utf-16", "utf-32"] 636s ): 636s warnings.warn( 636s f"{compression} will not write the byte order mark for {encoding}", 636s UnicodeWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s # Use binary mode when converting path-like objects to file-like objects (fsspec) 636s # except when text mode is explicitly requested. The original mode is returned if 636s # fsspec is not used. 636s fsspec_mode = mode 636s if "t" not in fsspec_mode and "b" not in fsspec_mode: 636s fsspec_mode += "b" 636s 636s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 636s # TODO: fsspec can also handle HTTP via requests, but leaving this 636s # unchanged. using fsspec appears to break the ability to infer if the 636s # server responded with gzipped data 636s storage_options = storage_options or {} 636s 636s # waiting until now for importing to match intended lazy logic of 636s # urlopen function defined elsewhere in this module 636s import urllib.request 636s 636s # assuming storage_options is to be interpreted as headers 636s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 636s > with urlopen(req_info) as req: 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s args = (,), kwargs = {} 636s urllib = 636s 636s def urlopen(*args, **kwargs): 636s """ 636s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 636s the stdlib. 636s """ 636s import urllib.request 636s 636s > return urllib.request.urlopen(*args, **kwargs) 636s 636s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s url = , data = None 636s timeout = 636s 636s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 636s *, context=None): 636s '''Open the URL url, which can be either a string or a Request object. 636s 636s *data* must be an object specifying additional data to be sent to 636s the server, or None if no such data is needed. See Request for 636s details. 636s 636s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 636s header in its HTTP requests. 636s 636s The optional *timeout* parameter specifies a timeout in seconds for 636s blocking operations like the connection attempt (if not specified, the 636s global default timeout setting will be used). This only works for HTTP, 636s HTTPS and FTP connections. 636s 636s If *context* is specified, it must be a ssl.SSLContext instance describing 636s the various SSL options. See HTTPSConnection for more details. 636s 636s 636s This function always returns an object which can work as a 636s context manager and has the properties url, headers, and status. 636s See urllib.response.addinfourl for more detail on these properties. 636s 636s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 636s object slightly modified. In addition to the three new methods above, the 636s msg attribute contains the same information as the reason attribute --- 636s the reason phrase returned by the server --- instead of the response 636s headers as it is specified in the documentation for HTTPResponse. 636s 636s For FTP, file, and data URLs and requests explicitly handled by legacy 636s URLopener and FancyURLopener classes, this function returns a 636s urllib.response.addinfourl object. 636s 636s Note that None may be returned if no handler handles the request (though 636s the default installed global OpenerDirector uses UnknownHandler to ensure 636s this never happens). 636s 636s In addition, if proxy settings are detected (for example, when a *_proxy 636s environment variable like http_proxy is set), ProxyHandler is default 636s installed and makes sure the requests are handled through the proxy. 636s 636s ''' 636s global _opener 636s if context: 636s https_handler = HTTPSHandler(context=context) 636s opener = build_opener(https_handler) 636s elif _opener is None: 636s _opener = opener = build_opener() 636s else: 636s opener = _opener 636s > return opener.open(url, data, timeout) 636s 636s /usr/lib/python3.13/urllib/request.py:189: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s fullurl = , data = None 636s timeout = 636s 636s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 636s # accept a URL or a Request object 636s if isinstance(fullurl, str): 636s req = Request(fullurl, data) 636s else: 636s req = fullurl 636s if data is not None: 636s req.data = data 636s 636s req.timeout = timeout 636s protocol = req.type 636s 636s # pre-process request 636s meth_name = protocol+"_request" 636s for processor in self.process_request.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s req = meth(req) 636s 636s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 636s response = self._open(req, data) 636s 636s # post-process response 636s meth_name = protocol+"_response" 636s for processor in self.process_response.get(protocol, []): 636s meth = getattr(processor, meth_name) 636s > response = meth(req, response) 636s 636s /usr/lib/python3.13/urllib/request.py:495: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s request = 636s response = 636s 636s def http_response(self, request, response): 636s code, msg, hdrs = response.code, response.msg, response.info() 636s 636s # According to RFC 2616, "2xx" code indicates that the client's 636s # request was successfully received, understood, and accepted. 636s if not (200 <= code < 300): 636s > response = self.parent.error( 636s 'http', request, response, code, msg, hdrs) 636s 636s /usr/lib/python3.13/urllib/request.py:604: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = , proto = 503 636s args = ({'default': [], 301: [, , 503, ...) 636s dict = {'default': [], 301: [], 303: [], ...} 636s meth_name = 'http_error_503', http_err = 1 636s 636s def error(self, proto, *args): 636s if proto in ('http', 'https'): 636s # XXX http[s] protocols are special-cased 636s dict = self.handle_error['http'] # https is not different than http 636s proto = args[2] # YUCK! 636s meth_name = 'http_error_%s' % proto 636s http_err = 1 636s orig_args = args 636s else: 636s dict = self.handle_error 636s meth_name = proto + '_error' 636s http_err = 0 636s args = (dict, proto, meth_name) + args 636s result = self._call_chain(*args) 636s if result: 636s return result 636s 636s if http_err: 636s args = (dict, 'default', 'http_error_default') + orig_args 636s > return self._call_chain(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:533: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s chain = {'default': [], 301: [], 303: [], ...} 636s kind = 'default', meth_name = 'http_error_default' 636s args = (, , 503, 'Service Unavailable', ) 636s handlers = [] 636s handler = 636s func = > 636s 636s def _call_chain(self, chain, kind, meth_name, *args): 636s # Handlers raise an exception if no one else should try to handle 636s # the request, or return None if they can't but another handler 636s # could. Otherwise, they return the response. 636s handlers = chain.get(kind, ()) 636s for handler in handlers: 636s func = getattr(handler, meth_name) 636s > result = func(*args) 636s 636s /usr/lib/python3.13/urllib/request.py:466: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s req = 636s fp = , code = 503 636s msg = 'Service Unavailable' 636s hdrs = 636s 636s def http_error_default(self, req, fp, code, msg, hdrs): 636s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 636s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 636s 636s /usr/lib/python3.13/urllib/request.py:613: HTTPError 636s _______ test_request_headers[storage_options2-gz_csv_responder-read_csv] _______ 636s 636s responder = 636s read_method = 636s httpserver = , started 133469846726336)> 636s storage_options = {'Auth': 'bar', 'Content-Encoding': 'gzip', 'User-Agent': 'foo'} 636s 636s @pytest.mark.parametrize( 636s "responder, read_method", 636s [ 636s (csv_responder, pd.read_csv), 636s (json_responder, pd.read_json), 636s ( 636s html_responder, 636s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 636s ), 636s pytest.param( 636s parquetpyarrow_reponder, 636s partial(pd.read_parquet, engine="pyarrow"), 636s marks=td.skip_if_no("pyarrow"), 636s ), 636s pytest.param( 636s parquetfastparquet_responder, 636s partial(pd.read_parquet, engine="fastparquet"), 636s # TODO(ArrayManager) fastparquet 636s marks=[ 636s td.skip_if_no("fastparquet"), 636s td.skip_if_no("fsspec"), 636s td.skip_array_manager_not_yet_implemented, 636s ], 636s ), 636s (pickle_respnder, pd.read_pickle), 636s (stata_responder, pd.read_stata), 636s (gz_csv_responder, pd.read_csv), 636s (gz_json_responder, pd.read_json), 636s ], 636s ) 636s @pytest.mark.parametrize( 636s "storage_options", 636s [ 636s None, 636s {"User-Agent": "foo"}, 636s {"User-Agent": "foo", "Auth": "bar"}, 636s ], 636s ) 636s def test_request_headers(responder, read_method, httpserver, storage_options): 636s expected = pd.DataFrame({"a": ["b"]}) 636s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 636s if "gz" in responder.__name__: 636s extra = {"Content-Encoding": "gzip"} 636s if storage_options is None: 636s storage_options = extra 636s else: 636s storage_options |= extra 636s else: 636s extra = None 636s expected_headers = set(default_headers).union( 636s storage_options.keys() if storage_options else [] 636s ) 636s httpserver.serve_content(content=responder(expected), headers=extra) 636s > result = read_method(httpserver.url, storage_options=storage_options) 636s 636s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:36153' 636s 636s @Appender( 636s _doc_read_csv_and_table.format( 636s func_name="read_csv", 636s summary="Read a comma-separated values (csv) file into DataFrame.", 636s see_also_func_name="read_table", 636s see_also_func_summary="Read general delimited file into DataFrame.", 636s _default_sep="','", 636s storage_options=_shared_docs["storage_options"], 636s decompression_options=_shared_docs["decompression_options"] 636s % "filepath_or_buffer", 636s ) 636s ) 636s def read_csv( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], 636s *, 636s sep: str | None | lib.NoDefault = lib.no_default, 636s delimiter: str | None | lib.NoDefault = None, 636s # Column and Index Locations and Names 636s header: int | Sequence[int] | None | Literal["infer"] = "infer", 636s names: Sequence[Hashable] | None | lib.NoDefault = lib.no_default, 636s index_col: IndexLabel | Literal[False] | None = None, 636s usecols: UsecolsArgType = None, 636s # General Parsing Configuration 636s dtype: DtypeArg | None = None, 636s engine: CSVEngine | None = None, 636s converters: Mapping[Hashable, Callable] | None = None, 636s true_values: list | None = None, 636s false_values: list | None = None, 636s skipinitialspace: bool = False, 636s skiprows: list[int] | int | Callable[[Hashable], bool] | None = None, 636s skipfooter: int = 0, 636s nrows: int | None = None, 636s # NA and Missing Data Handling 636s na_values: Hashable 636s | Iterable[Hashable] 636s | Mapping[Hashable, Iterable[Hashable]] 636s | None = None, 636s keep_default_na: bool = True, 636s na_filter: bool = True, 636s verbose: bool | lib.NoDefault = lib.no_default, 636s skip_blank_lines: bool = True, 636s # Datetime Handling 636s parse_dates: bool | Sequence[Hashable] | None = None, 636s infer_datetime_format: bool | lib.NoDefault = lib.no_default, 636s keep_date_col: bool | lib.NoDefault = lib.no_default, 636s date_parser: Callable | lib.NoDefault = lib.no_default, 636s date_format: str | dict[Hashable, str] | None = None, 636s dayfirst: bool = False, 636s cache_dates: bool = True, 636s # Iteration 636s iterator: bool = False, 636s chunksize: int | None = None, 636s # Quoting, Compression, and File Format 636s compression: CompressionOptions = "infer", 636s thousands: str | None = None, 636s decimal: str = ".", 636s lineterminator: str | None = None, 636s quotechar: str = '"', 636s quoting: int = csv.QUOTE_MINIMAL, 636s doublequote: bool = True, 636s escapechar: str | None = None, 636s comment: str | None = None, 636s encoding: str | None = None, 636s encoding_errors: str | None = "strict", 636s dialect: str | csv.Dialect | None = None, 636s # Error Handling 636s on_bad_lines: str = "error", 636s # Internal 636s delim_whitespace: bool | lib.NoDefault = lib.no_default, 636s low_memory: bool = _c_parser_defaults["low_memory"], 636s memory_map: bool = False, 636s float_precision: Literal["high", "legacy"] | None = None, 636s storage_options: StorageOptions | None = None, 636s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 636s ) -> DataFrame | TextFileReader: 636s if keep_date_col is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'keep_date_col' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Explicitly remove unwanted " 636s "columns after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s keep_date_col = False 636s 636s if lib.is_list_like(parse_dates): 636s # GH#55569 636s depr = False 636s # error: Item "bool" of "bool | Sequence[Hashable] | None" has no 636s # attribute "__iter__" (not iterable) 636s if not all(is_hashable(x) for x in parse_dates): # type: ignore[union-attr] 636s depr = True 636s elif isinstance(parse_dates, dict) and any( 636s lib.is_list_like(x) for x in parse_dates.values() 636s ): 636s depr = True 636s if depr: 636s warnings.warn( 636s "Support for nested sequences for 'parse_dates' in pd.read_csv " 636s "is deprecated. Combine the desired columns with pd.to_datetime " 636s "after parsing instead.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if infer_datetime_format is not lib.no_default: 636s warnings.warn( 636s "The argument 'infer_datetime_format' is deprecated and will " 636s "be removed in a future version. " 636s "A strict version of it is now the default, see " 636s "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. " 636s "You can safely remove this argument.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s 636s if delim_whitespace is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'delim_whitespace' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version. Use ``sep='\\s+'`` instead", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s delim_whitespace = False 636s 636s if verbose is not lib.no_default: 636s # GH#55569 636s warnings.warn( 636s "The 'verbose' keyword in pd.read_csv is deprecated and " 636s "will be removed in a future version.", 636s FutureWarning, 636s stacklevel=find_stack_level(), 636s ) 636s else: 636s verbose = False 636s 636s # locals() should never be modified 636s kwds = locals().copy() 636s del kwds["filepath_or_buffer"] 636s del kwds["sep"] 636s 636s kwds_defaults = _refine_defaults_read( 636s dialect, 636s delimiter, 636s delim_whitespace, 636s engine, 636s sep, 636s on_bad_lines, 636s names, 636s defaults={"delimiter": ","}, 636s dtype_backend=dtype_backend, 636s ) 636s kwds.update(kwds_defaults) 636s 636s > return _read(filepath_or_buffer, kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1026: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s filepath_or_buffer = 'http://127.0.0.1:36153' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s 636s def _read( 636s filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str], kwds 636s ) -> DataFrame | TextFileReader: 636s """Generic reader of line files.""" 636s # if we pass a date_parser and parse_dates=False, we should not parse the 636s # dates GH#44366 636s if kwds.get("parse_dates", None) is None: 636s if ( 636s kwds.get("date_parser", lib.no_default) is lib.no_default 636s and kwds.get("date_format", None) is None 636s ): 636s kwds["parse_dates"] = False 636s else: 636s kwds["parse_dates"] = True 636s 636s # Extract some of the arguments (pass chunksize on). 636s iterator = kwds.get("iterator", False) 636s chunksize = kwds.get("chunksize", None) 636s if kwds.get("engine") == "pyarrow": 636s if iterator: 636s raise ValueError( 636s "The 'iterator' option is not supported with the 'pyarrow' engine" 636s ) 636s 636s if chunksize is not None: 636s raise ValueError( 636s "The 'chunksize' option is not supported with the 'pyarrow' engine" 636s ) 636s else: 636s chunksize = validate_integer("chunksize", chunksize, 1) 636s 636s nrows = kwds.get("nrows", None) 636s 636s # Check for duplicates in names. 636s _validate_names(kwds.get("names", None)) 636s 636s # Create the parser. 636s > parser = TextFileReader(filepath_or_buffer, **kwds) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:36153', engine = 'c' 636s kwds = {'cache_dates': True, 'chunksize': None, 'comment': None, 'compression': 'infer', ...} 636s engine_specified = True, dialect = None 636s options = {'cache_dates': True, 'comment': None, 'compression': 'infer', 'converters': None, ...} 636s 636s def __init__( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list, 636s engine: CSVEngine | None = None, 636s **kwds, 636s ) -> None: 636s if engine is not None: 636s engine_specified = True 636s else: 636s engine = "python" 636s engine_specified = False 636s self.engine = engine 636s self._engine_specified = kwds.get("engine_specified", engine_specified) 636s 636s _validate_skipfooter(kwds) 636s 636s dialect = _extract_dialect(kwds) 636s if dialect is not None: 636s if engine == "pyarrow": 636s raise ValueError( 636s "The 'dialect' option is not supported with the 'pyarrow' engine" 636s ) 636s kwds = _merge_with_dialect_properties(dialect, kwds) 636s 636s if kwds.get("header", "infer") == "infer": 636s kwds["header"] = 0 if kwds.get("names") is None else None 636s 636s self.orig_options = kwds 636s 636s # miscellanea 636s self._currow = 0 636s 636s options = self._get_options_with_defaults(engine) 636s options["storage_options"] = kwds.get("storage_options", None) 636s 636s self.chunksize = options.pop("chunksize", None) 636s self.nrows = options.pop("nrows", None) 636s 636s self._check_file_or_buffer(f, engine) 636s self.options, self.engine = self._clean_options(options, engine) 636s 636s if "has_index_names" in kwds: 636s self.options["has_index_names"] = kwds["has_index_names"] 636s 636s self.handles: IOHandles | None = None 636s > self._engine = self._make_engine(f, self.engine) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1620: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s self = 636s f = 'http://127.0.0.1:36153', engine = 'c' 636s 636s def _make_engine( 636s self, 636s f: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str] | list | IO, 636s engine: CSVEngine = "c", 636s ) -> ParserBase: 636s mapping: dict[str, type[ParserBase]] = { 636s "c": CParserWrapper, 636s "python": PythonParser, 636s "pyarrow": ArrowParserWrapper, 636s "python-fwf": FixedWidthFieldParser, 636s } 636s if engine not in mapping: 636s raise ValueError( 636s f"Unknown engine: {engine} (valid options are {mapping.keys()})" 636s ) 636s if not isinstance(f, list): 636s # open file here 636s is_text = True 636s mode = "r" 636s if engine == "pyarrow": 636s is_text = False 636s mode = "rb" 636s elif ( 636s engine == "c" 636s and self.options.get("encoding", "utf-8") == "utf-8" 636s and isinstance(stringify_path(f), str) 636s ): 636s # c engine can decode utf-8 bytes, adding TextIOWrapper makes 636s # the c-engine especially for memory_map=True far slower 636s is_text = False 636s if "b" not in mode: 636s mode += "b" 636s > self.handles = get_handle( 636s f, 636s mode, 636s encoding=self.options.get("encoding", None), 636s compression=self.options.get("compression", None), 636s memory_map=self.options.get("memory_map", False), 636s is_text=is_text, 636s errors=self.options.get("encoding_errors", "strict"), 636s storage_options=self.options.get("storage_options", None), 636s ) 636s 636s /usr/lib/python3/dist-packages/pandas/io/parsers/readers.py:1880: 636s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 636s 636s path_or_buf = 'http://127.0.0.1:36153', mode = 'r' 636s 636s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 636s def get_handle( 636s path_or_buf: FilePath | BaseBuffer, 636s mode: str, 636s *, 636s encoding: str | None = None, 636s compression: CompressionOptions | None = None, 636s memory_map: bool = False, 636s is_text: bool = True, 636s errors: str | None = None, 636s storage_options: StorageOptions | None = None, 636s ) -> IOHandles[str] | IOHandles[bytes]: 636s """ 636s Get file handle for given path/buffer and mode. 636s 636s Parameters 636s ---------- 636s path_or_buf : str or file handle 636s File path or object. 636s mode : str 636s Mode to open path_or_buf with. 636s encoding : str or None 636s Encoding to use. 636s {compression_options} 636s 636s May be a dict with key 'method' as compression mode 636s and other keys as compression options if compression 636s mode is 'zip'. 636s 636s Passing compression options as keys in dict is 636s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 636s 636s .. versionchanged:: 1.4.0 Zstandard support. 636s 636s memory_map : bool, default False 636s See parsers._parser_params for more information. Only used by read_csv. 636s is_text : bool, default True 636s Whether the type of the content passed to the file/buffer is string or 636s bytes. This is not the same as `"b" not in mode`. If a string content is 636s passed to a binary file/buffer, a wrapper is inserted. 636s errors : str, default 'strict' 636s Specifies how encoding and decoding errors are to be handled. 636s See the errors argument for :func:`open` for a full list 636s of options. 636s storage_options: StorageOptions = None 637s Passed to _get_filepath_or_buffer 637s 637s Returns the dataclass IOHandles 637s """ 637s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 637s encoding = encoding or "utf-8" 637s 637s errors = errors or "strict" 637s 637s # read_csv does not know whether the buffer is opened in binary/text mode 637s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 637s mode += "b" 637s 637s # validate encoding and errors 637s codecs.lookup(encoding) 637s if isinstance(errors, str): 637s codecs.lookup_error(errors) 637s 637s # open URLs 637s > ioargs = _get_filepath_or_buffer( 637s path_or_buf, 637s encoding=encoding, 637s compression=compression, 637s mode=mode, 637s storage_options=storage_options, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s filepath_or_buffer = 'http://127.0.0.1:36153', encoding = 'utf-8' 637s compression = {'method': None}, mode = 'r' 637s storage_options = {'Auth': 'bar', 'Content-Encoding': 'gzip', 'User-Agent': 'foo'} 637s 637s @doc( 637s storage_options=_shared_docs["storage_options"], 637s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 637s ) 637s def _get_filepath_or_buffer( 637s filepath_or_buffer: FilePath | BaseBuffer, 637s encoding: str = "utf-8", 637s compression: CompressionOptions | None = None, 637s mode: str = "r", 637s storage_options: StorageOptions | None = None, 637s ) -> IOArgs: 637s """ 637s If the filepath_or_buffer is a url, translate and return the buffer. 637s Otherwise passthrough. 637s 637s Parameters 637s ---------- 637s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 637s or buffer 637s {compression_options} 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s encoding : the encoding to use to decode bytes, default is 'utf-8' 637s mode : str, optional 637s 637s {storage_options} 637s 637s 637s Returns the dataclass IOArgs. 637s """ 637s filepath_or_buffer = stringify_path(filepath_or_buffer) 637s 637s # handle compression dict 637s compression_method, compression = get_compression_method(compression) 637s compression_method = infer_compression(filepath_or_buffer, compression_method) 637s 637s # GH21227 internal compression is not used for non-binary handles. 637s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 637s warnings.warn( 637s "compression has no effect when passing a non-binary object as input.", 637s RuntimeWarning, 637s stacklevel=find_stack_level(), 637s ) 637s compression_method = None 637s 637s compression = dict(compression, method=compression_method) 637s 637s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 637s # print a warning when writing such files 637s if ( 637s "w" in mode 637s and compression_method in ["bz2", "xz"] 637s and encoding in ["utf-16", "utf-32"] 637s ): 637s warnings.warn( 637s f"{compression} will not write the byte order mark for {encoding}", 637s UnicodeWarning, 637s stacklevel=find_stack_level(), 637s ) 637s 637s # Use binary mode when converting path-like objects to file-like objects (fsspec) 637s # except when text mode is explicitly requested. The original mode is returned if 637s # fsspec is not used. 637s fsspec_mode = mode 637s if "t" not in fsspec_mode and "b" not in fsspec_mode: 637s fsspec_mode += "b" 637s 637s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 637s # TODO: fsspec can also handle HTTP via requests, but leaving this 637s # unchanged. using fsspec appears to break the ability to infer if the 637s # server responded with gzipped data 637s storage_options = storage_options or {} 637s 637s # waiting until now for importing to match intended lazy logic of 637s # urlopen function defined elsewhere in this module 637s import urllib.request 637s 637s # assuming storage_options is to be interpreted as headers 637s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 637s > with urlopen(req_info) as req: 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s args = (,), kwargs = {} 637s urllib = 637s 637s def urlopen(*args, **kwargs): 637s """ 637s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 637s the stdlib. 637s """ 637s import urllib.request 637s 637s > return urllib.request.urlopen(*args, **kwargs) 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s url = , data = None 637s timeout = 637s 637s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 637s *, context=None): 637s '''Open the URL url, which can be either a string or a Request object. 637s 637s *data* must be an object specifying additional data to be sent to 637s the server, or None if no such data is needed. See Request for 637s details. 637s 637s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 637s header in its HTTP requests. 637s 637s The optional *timeout* parameter specifies a timeout in seconds for 637s blocking operations like the connection attempt (if not specified, the 637s global default timeout setting will be used). This only works for HTTP, 637s HTTPS and FTP connections. 637s 637s If *context* is specified, it must be a ssl.SSLContext instance describing 637s the various SSL options. See HTTPSConnection for more details. 637s 637s 637s This function always returns an object which can work as a 637s context manager and has the properties url, headers, and status. 637s See urllib.response.addinfourl for more detail on these properties. 637s 637s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 637s object slightly modified. In addition to the three new methods above, the 637s msg attribute contains the same information as the reason attribute --- 637s the reason phrase returned by the server --- instead of the response 637s headers as it is specified in the documentation for HTTPResponse. 637s 637s For FTP, file, and data URLs and requests explicitly handled by legacy 637s URLopener and FancyURLopener classes, this function returns a 637s urllib.response.addinfourl object. 637s 637s Note that None may be returned if no handler handles the request (though 637s the default installed global OpenerDirector uses UnknownHandler to ensure 637s this never happens). 637s 637s In addition, if proxy settings are detected (for example, when a *_proxy 637s environment variable like http_proxy is set), ProxyHandler is default 637s installed and makes sure the requests are handled through the proxy. 637s 637s ''' 637s global _opener 637s if context: 637s https_handler = HTTPSHandler(context=context) 637s opener = build_opener(https_handler) 637s elif _opener is None: 637s _opener = opener = build_opener() 637s else: 637s opener = _opener 637s > return opener.open(url, data, timeout) 637s 637s /usr/lib/python3.13/urllib/request.py:189: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s fullurl = , data = None 637s timeout = 637s 637s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 637s # accept a URL or a Request object 637s if isinstance(fullurl, str): 637s req = Request(fullurl, data) 637s else: 637s req = fullurl 637s if data is not None: 637s req.data = data 637s 637s req.timeout = timeout 637s protocol = req.type 637s 637s # pre-process request 637s meth_name = protocol+"_request" 637s for processor in self.process_request.get(protocol, []): 637s meth = getattr(processor, meth_name) 637s req = meth(req) 637s 637s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 637s response = self._open(req, data) 637s 637s # post-process response 637s meth_name = protocol+"_response" 637s for processor in self.process_response.get(protocol, []): 637s meth = getattr(processor, meth_name) 637s > response = meth(req, response) 637s 637s /usr/lib/python3.13/urllib/request.py:495: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s request = 637s response = 637s 637s def http_response(self, request, response): 637s code, msg, hdrs = response.code, response.msg, response.info() 637s 637s # According to RFC 2616, "2xx" code indicates that the client's 637s # request was successfully received, understood, and accepted. 637s if not (200 <= code < 300): 637s > response = self.parent.error( 637s 'http', request, response, code, msg, hdrs) 637s 637s /usr/lib/python3.13/urllib/request.py:604: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = , proto = 503 637s args = ({'default': [], 301: [, , 503, ...) 637s dict = {'default': [], 301: [], 303: [], ...} 637s meth_name = 'http_error_503', http_err = 1 637s 637s def error(self, proto, *args): 637s if proto in ('http', 'https'): 637s # XXX http[s] protocols are special-cased 637s dict = self.handle_error['http'] # https is not different than http 637s proto = args[2] # YUCK! 637s meth_name = 'http_error_%s' % proto 637s http_err = 1 637s orig_args = args 637s else: 637s dict = self.handle_error 637s meth_name = proto + '_error' 637s http_err = 0 637s args = (dict, proto, meth_name) + args 637s result = self._call_chain(*args) 637s if result: 637s return result 637s 637s if http_err: 637s args = (dict, 'default', 'http_error_default') + orig_args 637s > return self._call_chain(*args) 637s 637s /usr/lib/python3.13/urllib/request.py:533: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s chain = {'default': [], 301: [], 303: [], ...} 637s kind = 'default', meth_name = 'http_error_default' 637s args = (, , 503, 'Service Unavailable', ) 637s handlers = [] 637s handler = 637s func = > 637s 637s def _call_chain(self, chain, kind, meth_name, *args): 637s # Handlers raise an exception if no one else should try to handle 637s # the request, or return None if they can't but another handler 637s # could. Otherwise, they return the response. 637s handlers = chain.get(kind, ()) 637s for handler in handlers: 637s func = getattr(handler, meth_name) 637s > result = func(*args) 637s 637s /usr/lib/python3.13/urllib/request.py:466: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s req = 637s fp = , code = 503 637s msg = 'Service Unavailable' 637s hdrs = 637s 637s def http_error_default(self, req, fp, code, msg, hdrs): 637s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 637s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 637s 637s /usr/lib/python3.13/urllib/request.py:613: HTTPError 637s ______ test_request_headers[storage_options2-gz_json_responder-read_json] ______ 637s 637s responder = 637s read_method = 637s httpserver = , started 133469838333632)> 637s storage_options = {'Auth': 'bar', 'Content-Encoding': 'gzip', 'User-Agent': 'foo'} 637s 637s @pytest.mark.parametrize( 637s "responder, read_method", 637s [ 637s (csv_responder, pd.read_csv), 637s (json_responder, pd.read_json), 637s ( 637s html_responder, 637s lambda *args, **kwargs: pd.read_html(*args, **kwargs)[0], 637s ), 637s pytest.param( 637s parquetpyarrow_reponder, 637s partial(pd.read_parquet, engine="pyarrow"), 637s marks=td.skip_if_no("pyarrow"), 637s ), 637s pytest.param( 637s parquetfastparquet_responder, 637s partial(pd.read_parquet, engine="fastparquet"), 637s # TODO(ArrayManager) fastparquet 637s marks=[ 637s td.skip_if_no("fastparquet"), 637s td.skip_if_no("fsspec"), 637s td.skip_array_manager_not_yet_implemented, 637s ], 637s ), 637s (pickle_respnder, pd.read_pickle), 637s (stata_responder, pd.read_stata), 637s (gz_csv_responder, pd.read_csv), 637s (gz_json_responder, pd.read_json), 637s ], 637s ) 637s @pytest.mark.parametrize( 637s "storage_options", 637s [ 637s None, 637s {"User-Agent": "foo"}, 637s {"User-Agent": "foo", "Auth": "bar"}, 637s ], 637s ) 637s def test_request_headers(responder, read_method, httpserver, storage_options): 637s expected = pd.DataFrame({"a": ["b"]}) 637s default_headers = ["Accept-Encoding", "Host", "Connection", "User-Agent"] 637s if "gz" in responder.__name__: 637s extra = {"Content-Encoding": "gzip"} 637s if storage_options is None: 637s storage_options = extra 637s else: 637s storage_options |= extra 637s else: 637s extra = None 637s expected_headers = set(default_headers).union( 637s storage_options.keys() if storage_options else [] 637s ) 637s httpserver.serve_content(content=responder(expected), headers=extra) 637s > result = read_method(httpserver.url, storage_options=storage_options) 637s 637s /usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py:139: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buf = 'http://127.0.0.1:33001' 637s 637s @doc( 637s storage_options=_shared_docs["storage_options"], 637s decompression_options=_shared_docs["decompression_options"] % "path_or_buf", 637s ) 637s def read_json( 637s path_or_buf: FilePath | ReadBuffer[str] | ReadBuffer[bytes], 637s *, 637s orient: str | None = None, 637s typ: Literal["frame", "series"] = "frame", 637s dtype: DtypeArg | None = None, 637s convert_axes: bool | None = None, 637s convert_dates: bool | list[str] = True, 637s keep_default_dates: bool = True, 637s precise_float: bool = False, 637s date_unit: str | None = None, 637s encoding: str | None = None, 637s encoding_errors: str | None = "strict", 637s lines: bool = False, 637s chunksize: int | None = None, 637s compression: CompressionOptions = "infer", 637s nrows: int | None = None, 637s storage_options: StorageOptions | None = None, 637s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 637s engine: JSONEngine = "ujson", 637s ) -> DataFrame | Series | JsonReader: 637s """ 637s Convert a JSON string to pandas object. 637s 637s Parameters 637s ---------- 637s path_or_buf : a valid JSON str, path object or file-like object 637s Any valid string path is acceptable. The string could be a URL. Valid 637s URL schemes include http, ftp, s3, and file. For file URLs, a host is 637s expected. A local file could be: 637s ``file://localhost/path/to/table.json``. 637s 637s If you want to pass in a path object, pandas accepts any 637s ``os.PathLike``. 637s 637s By file-like object, we refer to objects with a ``read()`` method, 637s such as a file handle (e.g. via builtin ``open`` function) 637s or ``StringIO``. 637s 637s .. deprecated:: 2.1.0 637s Passing json literal strings is deprecated. 637s 637s orient : str, optional 637s Indication of expected JSON string format. 637s Compatible JSON strings can be produced by ``to_json()`` with a 637s corresponding orient value. 637s The set of possible orients is: 637s 637s - ``'split'`` : dict like 637s ``{{index -> [index], columns -> [columns], data -> [values]}}`` 637s - ``'records'`` : list like 637s ``[{{column -> value}}, ... , {{column -> value}}]`` 637s - ``'index'`` : dict like ``{{index -> {{column -> value}}}}`` 637s - ``'columns'`` : dict like ``{{column -> {{index -> value}}}}`` 637s - ``'values'`` : just the values array 637s - ``'table'`` : dict like ``{{'schema': {{schema}}, 'data': {{data}}}}`` 637s 637s The allowed and default values depend on the value 637s of the `typ` parameter. 637s 637s * when ``typ == 'series'``, 637s 637s - allowed orients are ``{{'split','records','index'}}`` 637s - default is ``'index'`` 637s - The Series index must be unique for orient ``'index'``. 637s 637s * when ``typ == 'frame'``, 637s 637s - allowed orients are ``{{'split','records','index', 637s 'columns','values', 'table'}}`` 637s - default is ``'columns'`` 637s - The DataFrame index must be unique for orients ``'index'`` and 637s ``'columns'``. 637s - The DataFrame columns must be unique for orients ``'index'``, 637s ``'columns'``, and ``'records'``. 637s 637s typ : {{'frame', 'series'}}, default 'frame' 637s The type of object to recover. 637s 637s dtype : bool or dict, default None 637s If True, infer dtypes; if a dict of column to dtype, then use those; 637s if False, then don't infer dtypes at all, applies only to the data. 637s 637s For all ``orient`` values except ``'table'``, default is True. 637s 637s convert_axes : bool, default None 637s Try to convert the axes to the proper dtypes. 637s 637s For all ``orient`` values except ``'table'``, default is True. 637s 637s convert_dates : bool or list of str, default True 637s If True then default datelike columns may be converted (depending on 637s keep_default_dates). 637s If False, no dates will be converted. 637s If a list of column names, then those columns will be converted and 637s default datelike columns may also be converted (depending on 637s keep_default_dates). 637s 637s keep_default_dates : bool, default True 637s If parsing dates (convert_dates is not False), then try to parse the 637s default datelike columns. 637s A column label is datelike if 637s 637s * it ends with ``'_at'``, 637s 637s * it ends with ``'_time'``, 637s 637s * it begins with ``'timestamp'``, 637s 637s * it is ``'modified'``, or 637s 637s * it is ``'date'``. 637s 637s precise_float : bool, default False 637s Set to enable usage of higher precision (strtod) function when 637s decoding string to double values. Default (False) is to use fast but 637s less precise builtin functionality. 637s 637s date_unit : str, default None 637s The timestamp unit to detect if converting dates. The default behaviour 637s is to try and detect the correct precision, but if this is not desired 637s then pass one of 's', 'ms', 'us' or 'ns' to force parsing only seconds, 637s milliseconds, microseconds or nanoseconds respectively. 637s 637s encoding : str, default is 'utf-8' 637s The encoding to use to decode py3 bytes. 637s 637s encoding_errors : str, optional, default "strict" 637s How encoding errors are treated. `List of possible values 637s `_ . 637s 637s .. versionadded:: 1.3.0 637s 637s lines : bool, default False 637s Read the file as a json object per line. 637s 637s chunksize : int, optional 637s Return JsonReader object for iteration. 637s See the `line-delimited json docs 637s `_ 637s for more information on ``chunksize``. 637s This can only be passed if `lines=True`. 637s If this is None, the file will be read into memory all at once. 637s {decompression_options} 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s nrows : int, optional 637s The number of lines from the line-delimited jsonfile that has to be read. 637s This can only be passed if `lines=True`. 637s If this is None, all the rows will be returned. 637s 637s {storage_options} 637s 637s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 637s Back-end data type applied to the resultant :class:`DataFrame` 637s (still experimental). Behaviour is as follows: 637s 637s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 637s (default). 637s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 637s DataFrame. 637s 637s .. versionadded:: 2.0 637s 637s engine : {{"ujson", "pyarrow"}}, default "ujson" 637s Parser engine to use. The ``"pyarrow"`` engine is only available when 637s ``lines=True``. 637s 637s .. versionadded:: 2.0 637s 637s Returns 637s ------- 637s Series, DataFrame, or pandas.api.typing.JsonReader 637s A JsonReader is returned when ``chunksize`` is not ``0`` or ``None``. 637s Otherwise, the type returned depends on the value of ``typ``. 637s 637s See Also 637s -------- 637s DataFrame.to_json : Convert a DataFrame to a JSON string. 637s Series.to_json : Convert a Series to a JSON string. 637s json_normalize : Normalize semi-structured JSON data into a flat table. 637s 637s Notes 637s ----- 637s Specific to ``orient='table'``, if a :class:`DataFrame` with a literal 637s :class:`Index` name of `index` gets written with :func:`to_json`, the 637s subsequent read operation will incorrectly set the :class:`Index` name to 637s ``None``. This is because `index` is also used by :func:`DataFrame.to_json` 637s to denote a missing :class:`Index` name, and the subsequent 637s :func:`read_json` operation cannot distinguish between the two. The same 637s limitation is encountered with a :class:`MultiIndex` and any names 637s beginning with ``'level_'``. 637s 637s Examples 637s -------- 637s >>> from io import StringIO 637s >>> df = pd.DataFrame([['a', 'b'], ['c', 'd']], 637s ... index=['row 1', 'row 2'], 637s ... columns=['col 1', 'col 2']) 637s 637s Encoding/decoding a Dataframe using ``'split'`` formatted JSON: 637s 637s >>> df.to_json(orient='split') 637s '\ 637s {{\ 637s "columns":["col 1","col 2"],\ 637s "index":["row 1","row 2"],\ 637s "data":[["a","b"],["c","d"]]\ 637s }}\ 637s ' 637s >>> pd.read_json(StringIO(_), orient='split') 637s col 1 col 2 637s row 1 a b 637s row 2 c d 637s 637s Encoding/decoding a Dataframe using ``'index'`` formatted JSON: 637s 637s >>> df.to_json(orient='index') 637s '{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}' 637s 637s >>> pd.read_json(StringIO(_), orient='index') 637s col 1 col 2 637s row 1 a b 637s row 2 c d 637s 637s Encoding/decoding a Dataframe using ``'records'`` formatted JSON. 637s Note that index labels are not preserved with this encoding. 637s 637s >>> df.to_json(orient='records') 637s '[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]' 637s >>> pd.read_json(StringIO(_), orient='records') 637s col 1 col 2 637s 0 a b 637s 1 c d 637s 637s Encoding with Table Schema 637s 637s >>> df.to_json(orient='table') 637s '\ 637s {{"schema":{{"fields":[\ 637s {{"name":"index","type":"string"}},\ 637s {{"name":"col 1","type":"string"}},\ 637s {{"name":"col 2","type":"string"}}],\ 637s "primaryKey":["index"],\ 637s "pandas_version":"1.4.0"}},\ 637s "data":[\ 637s {{"index":"row 1","col 1":"a","col 2":"b"}},\ 637s {{"index":"row 2","col 1":"c","col 2":"d"}}]\ 637s }}\ 637s ' 637s 637s The following example uses ``dtype_backend="numpy_nullable"`` 637s 637s >>> data = '''{{"index": {{"0": 0, "1": 1}}, 637s ... "a": {{"0": 1, "1": null}}, 637s ... "b": {{"0": 2.5, "1": 4.5}}, 637s ... "c": {{"0": true, "1": false}}, 637s ... "d": {{"0": "a", "1": "b"}}, 637s ... "e": {{"0": 1577.2, "1": 1577.1}}}}''' 637s >>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable") 637s index a b c d e 637s 0 0 1 2.5 True a 1577.2 637s 1 1 4.5 False b 1577.1 637s """ 637s if orient == "table" and dtype: 637s raise ValueError("cannot pass both dtype and orient='table'") 637s if orient == "table" and convert_axes: 637s raise ValueError("cannot pass both convert_axes and orient='table'") 637s 637s check_dtype_backend(dtype_backend) 637s 637s if dtype is None and orient != "table": 637s # error: Incompatible types in assignment (expression has type "bool", variable 637s # has type "Union[ExtensionDtype, str, dtype[Any], Type[str], Type[float], 637s # Type[int], Type[complex], Type[bool], Type[object], Dict[Hashable, 637s # Union[ExtensionDtype, Union[str, dtype[Any]], Type[str], Type[float], 637s # Type[int], Type[complex], Type[bool], Type[object]]], None]") 637s dtype = True # type: ignore[assignment] 637s if convert_axes is None and orient != "table": 637s convert_axes = True 637s 637s > json_reader = JsonReader( 637s path_or_buf, 637s orient=orient, 637s typ=typ, 637s dtype=dtype, 637s convert_axes=convert_axes, 637s convert_dates=convert_dates, 637s keep_default_dates=keep_default_dates, 637s precise_float=precise_float, 637s date_unit=date_unit, 637s encoding=encoding, 637s lines=lines, 637s chunksize=chunksize, 637s compression=compression, 637s nrows=nrows, 637s storage_options=storage_options, 637s encoding_errors=encoding_errors, 637s dtype_backend=dtype_backend, 637s engine=engine, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:791: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s filepath_or_buffer = 'http://127.0.0.1:33001', orient = None, typ = 'frame' 637s dtype = True, convert_axes = True, convert_dates = True 637s keep_default_dates = True, precise_float = False, date_unit = None 637s encoding = None, lines = False, chunksize = None, compression = 'infer' 637s nrows = None 637s storage_options = {'Auth': 'bar', 'Content-Encoding': 'gzip', 'User-Agent': 'foo'} 637s encoding_errors = 'strict', dtype_backend = , engine = 'ujson' 637s 637s def __init__( 637s self, 637s filepath_or_buffer, 637s orient, 637s typ: FrameSeriesStrT, 637s dtype, 637s convert_axes: bool | None, 637s convert_dates, 637s keep_default_dates: bool, 637s precise_float: bool, 637s date_unit, 637s encoding, 637s lines: bool, 637s chunksize: int | None, 637s compression: CompressionOptions, 637s nrows: int | None, 637s storage_options: StorageOptions | None = None, 637s encoding_errors: str | None = "strict", 637s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 637s engine: JSONEngine = "ujson", 637s ) -> None: 637s self.orient = orient 637s self.typ = typ 637s self.dtype = dtype 637s self.convert_axes = convert_axes 637s self.convert_dates = convert_dates 637s self.keep_default_dates = keep_default_dates 637s self.precise_float = precise_float 637s self.date_unit = date_unit 637s self.encoding = encoding 637s self.engine = engine 637s self.compression = compression 637s self.storage_options = storage_options 637s self.lines = lines 637s self.chunksize = chunksize 637s self.nrows_seen = 0 637s self.nrows = nrows 637s self.encoding_errors = encoding_errors 637s self.handles: IOHandles[str] | None = None 637s self.dtype_backend = dtype_backend 637s 637s if self.engine not in {"pyarrow", "ujson"}: 637s raise ValueError( 637s f"The engine type {self.engine} is currently not supported." 637s ) 637s if self.chunksize is not None: 637s self.chunksize = validate_integer("chunksize", self.chunksize, 1) 637s if not self.lines: 637s raise ValueError("chunksize can only be passed if lines=True") 637s if self.engine == "pyarrow": 637s raise ValueError( 637s "currently pyarrow engine doesn't support chunksize parameter" 637s ) 637s if self.nrows is not None: 637s self.nrows = validate_integer("nrows", self.nrows, 0) 637s if not self.lines: 637s raise ValueError("nrows can only be passed if lines=True") 637s if ( 637s isinstance(filepath_or_buffer, str) 637s and not self.lines 637s and "\n" in filepath_or_buffer 637s ): 637s warnings.warn( 637s "Passing literal json to 'read_json' is deprecated and " 637s "will be removed in a future version. To read from a " 637s "literal string, wrap it in a 'StringIO' object.", 637s FutureWarning, 637s stacklevel=find_stack_level(), 637s ) 637s if self.engine == "pyarrow": 637s if not self.lines: 637s raise ValueError( 637s "currently pyarrow engine only supports " 637s "the line-delimited JSON format" 637s ) 637s self.data = filepath_or_buffer 637s elif self.engine == "ujson": 637s > data = self._get_data_from_filepath(filepath_or_buffer) 637s 637s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:904: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s filepath_or_buffer = 'http://127.0.0.1:33001' 637s 637s def _get_data_from_filepath(self, filepath_or_buffer): 637s """ 637s The function read_json accepts three input types: 637s 1. filepath (string-like) 637s 2. file-like object (e.g. open file object, StringIO) 637s 3. JSON string 637s 637s This method turns (1) into (2) to simplify the rest of the processing. 637s It returns input types (2) and (3) unchanged. 637s 637s It raises FileNotFoundError if the input is a string ending in 637s one of .json, .json.gz, .json.bz2, etc. but no such file exists. 637s """ 637s # if it is a string but the file does not exist, it might be a JSON string 637s filepath_or_buffer = stringify_path(filepath_or_buffer) 637s if ( 637s not isinstance(filepath_or_buffer, str) 637s or is_url(filepath_or_buffer) 637s or is_fsspec_url(filepath_or_buffer) 637s or file_exists(filepath_or_buffer) 637s ): 637s > self.handles = get_handle( 637s filepath_or_buffer, 637s "r", 637s encoding=self.encoding, 637s compression=self.compression, 637s storage_options=self.storage_options, 637s errors=self.encoding_errors, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/json/_json.py:944: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buf = 'http://127.0.0.1:33001', mode = 'r' 637s 637s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 637s def get_handle( 637s path_or_buf: FilePath | BaseBuffer, 637s mode: str, 637s *, 637s encoding: str | None = None, 637s compression: CompressionOptions | None = None, 637s memory_map: bool = False, 637s is_text: bool = True, 637s errors: str | None = None, 637s storage_options: StorageOptions | None = None, 637s ) -> IOHandles[str] | IOHandles[bytes]: 637s """ 637s Get file handle for given path/buffer and mode. 637s 637s Parameters 637s ---------- 637s path_or_buf : str or file handle 637s File path or object. 637s mode : str 637s Mode to open path_or_buf with. 637s encoding : str or None 637s Encoding to use. 637s {compression_options} 637s 637s May be a dict with key 'method' as compression mode 637s and other keys as compression options if compression 637s mode is 'zip'. 637s 637s Passing compression options as keys in dict is 637s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s memory_map : bool, default False 637s See parsers._parser_params for more information. Only used by read_csv. 637s is_text : bool, default True 637s Whether the type of the content passed to the file/buffer is string or 637s bytes. This is not the same as `"b" not in mode`. If a string content is 637s passed to a binary file/buffer, a wrapper is inserted. 637s errors : str, default 'strict' 637s Specifies how encoding and decoding errors are to be handled. 637s See the errors argument for :func:`open` for a full list 637s of options. 637s storage_options: StorageOptions = None 637s Passed to _get_filepath_or_buffer 637s 637s Returns the dataclass IOHandles 637s """ 637s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 637s encoding = encoding or "utf-8" 637s 637s errors = errors or "strict" 637s 637s # read_csv does not know whether the buffer is opened in binary/text mode 637s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 637s mode += "b" 637s 637s # validate encoding and errors 637s codecs.lookup(encoding) 637s if isinstance(errors, str): 637s codecs.lookup_error(errors) 637s 637s # open URLs 637s > ioargs = _get_filepath_or_buffer( 637s path_or_buf, 637s encoding=encoding, 637s compression=compression, 637s mode=mode, 637s storage_options=storage_options, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s filepath_or_buffer = 'http://127.0.0.1:33001', encoding = 'utf-8' 637s compression = {'method': None}, mode = 'r' 637s storage_options = {'Auth': 'bar', 'Content-Encoding': 'gzip', 'User-Agent': 'foo'} 637s 637s @doc( 637s storage_options=_shared_docs["storage_options"], 637s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 637s ) 637s def _get_filepath_or_buffer( 637s filepath_or_buffer: FilePath | BaseBuffer, 637s encoding: str = "utf-8", 637s compression: CompressionOptions | None = None, 637s mode: str = "r", 637s storage_options: StorageOptions | None = None, 637s ) -> IOArgs: 637s """ 637s If the filepath_or_buffer is a url, translate and return the buffer. 637s Otherwise passthrough. 637s 637s Parameters 637s ---------- 637s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 637s or buffer 637s {compression_options} 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s encoding : the encoding to use to decode bytes, default is 'utf-8' 637s mode : str, optional 637s 637s {storage_options} 637s 637s 637s Returns the dataclass IOArgs. 637s """ 637s filepath_or_buffer = stringify_path(filepath_or_buffer) 637s 637s # handle compression dict 637s compression_method, compression = get_compression_method(compression) 637s compression_method = infer_compression(filepath_or_buffer, compression_method) 637s 637s # GH21227 internal compression is not used for non-binary handles. 637s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 637s warnings.warn( 637s "compression has no effect when passing a non-binary object as input.", 637s RuntimeWarning, 637s stacklevel=find_stack_level(), 637s ) 637s compression_method = None 637s 637s compression = dict(compression, method=compression_method) 637s 637s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 637s # print a warning when writing such files 637s if ( 637s "w" in mode 637s and compression_method in ["bz2", "xz"] 637s and encoding in ["utf-16", "utf-32"] 637s ): 637s warnings.warn( 637s f"{compression} will not write the byte order mark for {encoding}", 637s UnicodeWarning, 637s stacklevel=find_stack_level(), 637s ) 637s 637s # Use binary mode when converting path-like objects to file-like objects (fsspec) 637s # except when text mode is explicitly requested. The original mode is returned if 637s # fsspec is not used. 637s fsspec_mode = mode 637s if "t" not in fsspec_mode and "b" not in fsspec_mode: 637s fsspec_mode += "b" 637s 637s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 637s # TODO: fsspec can also handle HTTP via requests, but leaving this 637s # unchanged. using fsspec appears to break the ability to infer if the 637s # server responded with gzipped data 637s storage_options = storage_options or {} 637s 637s # waiting until now for importing to match intended lazy logic of 637s # urlopen function defined elsewhere in this module 637s import urllib.request 637s 637s # assuming storage_options is to be interpreted as headers 637s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 637s > with urlopen(req_info) as req: 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s args = (,), kwargs = {} 637s urllib = 637s 637s def urlopen(*args, **kwargs): 637s """ 637s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 637s the stdlib. 637s """ 637s import urllib.request 637s 637s > return urllib.request.urlopen(*args, **kwargs) 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s url = , data = None 637s timeout = 637s 637s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 637s *, context=None): 637s '''Open the URL url, which can be either a string or a Request object. 637s 637s *data* must be an object specifying additional data to be sent to 637s the server, or None if no such data is needed. See Request for 637s details. 637s 637s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 637s header in its HTTP requests. 637s 637s The optional *timeout* parameter specifies a timeout in seconds for 637s blocking operations like the connection attempt (if not specified, the 637s global default timeout setting will be used). This only works for HTTP, 637s HTTPS and FTP connections. 637s 637s If *context* is specified, it must be a ssl.SSLContext instance describing 637s the various SSL options. See HTTPSConnection for more details. 637s 637s 637s This function always returns an object which can work as a 637s context manager and has the properties url, headers, and status. 637s See urllib.response.addinfourl for more detail on these properties. 637s 637s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 637s object slightly modified. In addition to the three new methods above, the 637s msg attribute contains the same information as the reason attribute --- 637s the reason phrase returned by the server --- instead of the response 637s headers as it is specified in the documentation for HTTPResponse. 637s 637s For FTP, file, and data URLs and requests explicitly handled by legacy 637s URLopener and FancyURLopener classes, this function returns a 637s urllib.response.addinfourl object. 637s 637s Note that None may be returned if no handler handles the request (though 637s the default installed global OpenerDirector uses UnknownHandler to ensure 637s this never happens). 637s 637s In addition, if proxy settings are detected (for example, when a *_proxy 637s environment variable like http_proxy is set), ProxyHandler is default 637s installed and makes sure the requests are handled through the proxy. 637s 637s ''' 637s global _opener 637s if context: 637s https_handler = HTTPSHandler(context=context) 637s opener = build_opener(https_handler) 637s elif _opener is None: 637s _opener = opener = build_opener() 637s else: 637s opener = _opener 637s > return opener.open(url, data, timeout) 637s 637s /usr/lib/python3.13/urllib/request.py:189: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s fullurl = , data = None 637s timeout = 637s 637s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 637s # accept a URL or a Request object 637s if isinstance(fullurl, str): 637s req = Request(fullurl, data) 637s else: 637s req = fullurl 637s if data is not None: 637s req.data = data 637s 637s req.timeout = timeout 637s protocol = req.type 637s 637s # pre-process request 637s meth_name = protocol+"_request" 637s for processor in self.process_request.get(protocol, []): 637s meth = getattr(processor, meth_name) 637s req = meth(req) 637s 637s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 637s response = self._open(req, data) 637s 637s # post-process response 637s meth_name = protocol+"_response" 637s for processor in self.process_response.get(protocol, []): 637s meth = getattr(processor, meth_name) 637s > response = meth(req, response) 637s 637s /usr/lib/python3.13/urllib/request.py:495: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s request = 637s response = 637s 637s def http_response(self, request, response): 637s code, msg, hdrs = response.code, response.msg, response.info() 637s 637s # According to RFC 2616, "2xx" code indicates that the client's 637s # request was successfully received, understood, and accepted. 637s if not (200 <= code < 300): 637s > response = self.parent.error( 637s 'http', request, response, code, msg, hdrs) 637s 637s /usr/lib/python3.13/urllib/request.py:604: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = , proto = 503 637s args = ({'default': [], 301: [, , 503, ...) 637s dict = {'default': [], 301: [], 303: [], ...} 637s meth_name = 'http_error_503', http_err = 1 637s 637s def error(self, proto, *args): 637s if proto in ('http', 'https'): 637s # XXX http[s] protocols are special-cased 637s dict = self.handle_error['http'] # https is not different than http 637s proto = args[2] # YUCK! 637s meth_name = 'http_error_%s' % proto 637s http_err = 1 637s orig_args = args 637s else: 637s dict = self.handle_error 637s meth_name = proto + '_error' 637s http_err = 0 637s args = (dict, proto, meth_name) + args 637s result = self._call_chain(*args) 637s if result: 637s return result 637s 637s if http_err: 637s args = (dict, 'default', 'http_error_default') + orig_args 637s > return self._call_chain(*args) 637s 637s /usr/lib/python3.13/urllib/request.py:533: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s chain = {'default': [], 301: [], 303: [], ...} 637s kind = 'default', meth_name = 'http_error_default' 637s args = (, , 503, 'Service Unavailable', ) 637s handlers = [] 637s handler = 637s func = > 637s 637s def _call_chain(self, chain, kind, meth_name, *args): 637s # Handlers raise an exception if no one else should try to handle 637s # the request, or return None if they can't but another handler 637s # could. Otherwise, they return the response. 637s handlers = chain.get(kind, ()) 637s for handler in handlers: 637s func = getattr(handler, meth_name) 637s > result = func(*args) 637s 637s /usr/lib/python3.13/urllib/request.py:466: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s req = 637s fp = , code = 503 637s msg = 'Service Unavailable' 637s hdrs = 637s 637s def http_error_default(self, req, fp, code, msg, hdrs): 637s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 637s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 637s 637s /usr/lib/python3.13/urllib/request.py:613: HTTPError 637s ___________________________________ test_url ___________________________________ 637s 637s httpserver = , started 133469796370112)> 637s xml_file = '/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests/io/data/xml/books.xml' 637s 637s @pytest.mark.network 637s @pytest.mark.single_cpu 637s def test_url(httpserver, xml_file): 637s td.versioned_importorskip("lxml") 637s with open(xml_file, encoding="utf-8") as f: 637s httpserver.serve_content(content=f.read()) 637s > df_url = read_xml(httpserver.url, xpath=".//book[count(*)=4]") 637s 637s /usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py:511: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buffer = 'http://127.0.0.1:40807' 637s 637s @doc( 637s storage_options=_shared_docs["storage_options"], 637s decompression_options=_shared_docs["decompression_options"] % "path_or_buffer", 637s ) 637s def read_xml( 637s path_or_buffer: FilePath | ReadBuffer[bytes] | ReadBuffer[str], 637s *, 637s xpath: str = "./*", 637s namespaces: dict[str, str] | None = None, 637s elems_only: bool = False, 637s attrs_only: bool = False, 637s names: Sequence[str] | None = None, 637s dtype: DtypeArg | None = None, 637s converters: ConvertersArg | None = None, 637s parse_dates: ParseDatesArg | None = None, 637s # encoding can not be None for lxml and StringIO input 637s encoding: str | None = "utf-8", 637s parser: XMLParsers = "lxml", 637s stylesheet: FilePath | ReadBuffer[bytes] | ReadBuffer[str] | None = None, 637s iterparse: dict[str, list[str]] | None = None, 637s compression: CompressionOptions = "infer", 637s storage_options: StorageOptions | None = None, 637s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 637s ) -> DataFrame: 637s r""" 637s Read XML document into a :class:`~pandas.DataFrame` object. 637s 637s .. versionadded:: 1.3.0 637s 637s Parameters 637s ---------- 637s path_or_buffer : str, path object, or file-like object 637s String, path object (implementing ``os.PathLike[str]``), or file-like 637s object implementing a ``read()`` function. The string can be any valid XML 637s string or a path. The string can further be a URL. Valid URL schemes 637s include http, ftp, s3, and file. 637s 637s .. deprecated:: 2.1.0 637s Passing xml literal strings is deprecated. 637s Wrap literal xml input in ``io.StringIO`` or ``io.BytesIO`` instead. 637s 637s xpath : str, optional, default './\*' 637s The ``XPath`` to parse required set of nodes for migration to 637s :class:`~pandas.DataFrame`.``XPath`` should return a collection of elements 637s and not a single element. Note: The ``etree`` parser supports limited ``XPath`` 637s expressions. For more complex ``XPath``, use ``lxml`` which requires 637s installation. 637s 637s namespaces : dict, optional 637s The namespaces defined in XML document as dicts with key being 637s namespace prefix and value the URI. There is no need to include all 637s namespaces in XML, only the ones used in ``xpath`` expression. 637s Note: if XML document uses default namespace denoted as 637s `xmlns=''` without a prefix, you must assign any temporary 637s namespace prefix such as 'doc' to the URI in order to parse 637s underlying nodes and/or attributes. For example, :: 637s 637s namespaces = {{"doc": "https://example.com"}} 637s 637s elems_only : bool, optional, default False 637s Parse only the child elements at the specified ``xpath``. By default, 637s all child elements and non-empty text nodes are returned. 637s 637s attrs_only : bool, optional, default False 637s Parse only the attributes at the specified ``xpath``. 637s By default, all attributes are returned. 637s 637s names : list-like, optional 637s Column names for DataFrame of parsed XML data. Use this parameter to 637s rename original element names and distinguish same named elements and 637s attributes. 637s 637s dtype : Type name or dict of column -> type, optional 637s Data type for data or columns. E.g. {{'a': np.float64, 'b': np.int32, 637s 'c': 'Int64'}} 637s Use `str` or `object` together with suitable `na_values` settings 637s to preserve and not interpret dtype. 637s If converters are specified, they will be applied INSTEAD 637s of dtype conversion. 637s 637s .. versionadded:: 1.5.0 637s 637s converters : dict, optional 637s Dict of functions for converting values in certain columns. Keys can either 637s be integers or column labels. 637s 637s .. versionadded:: 1.5.0 637s 637s parse_dates : bool or list of int or names or list of lists or dict, default False 637s Identifiers to parse index or columns to datetime. The behavior is as follows: 637s 637s * boolean. If True -> try parsing the index. 637s * list of int or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3 637s each as a separate date column. 637s * list of lists. e.g. If [[1, 3]] -> combine columns 1 and 3 and parse as 637s a single date column. 637s * dict, e.g. {{'foo' : [1, 3]}} -> parse columns 1, 3 as date and call 637s result 'foo' 637s 637s .. versionadded:: 1.5.0 637s 637s encoding : str, optional, default 'utf-8' 637s Encoding of XML document. 637s 637s parser : {{'lxml','etree'}}, default 'lxml' 637s Parser module to use for retrieval of data. Only 'lxml' and 637s 'etree' are supported. With 'lxml' more complex ``XPath`` searches 637s and ability to use XSLT stylesheet are supported. 637s 637s stylesheet : str, path object or file-like object 637s A URL, file-like object, or a raw string containing an XSLT script. 637s This stylesheet should flatten complex, deeply nested XML documents 637s for easier parsing. To use this feature you must have ``lxml`` module 637s installed and specify 'lxml' as ``parser``. The ``xpath`` must 637s reference nodes of transformed XML document generated after XSLT 637s transformation and not the original XML document. Only XSLT 1.0 637s scripts and not later versions is currently supported. 637s 637s iterparse : dict, optional 637s The nodes or attributes to retrieve in iterparsing of XML document 637s as a dict with key being the name of repeating element and value being 637s list of elements or attribute names that are descendants of the repeated 637s element. Note: If this option is used, it will replace ``xpath`` parsing 637s and unlike ``xpath``, descendants do not need to relate to each other but can 637s exist any where in document under the repeating element. This memory- 637s efficient method should be used for very large XML files (500MB, 1GB, or 5GB+). 637s For example, :: 637s 637s iterparse = {{"row_element": ["child_elem", "attr", "grandchild_elem"]}} 637s 637s .. versionadded:: 1.5.0 637s 637s {decompression_options} 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s {storage_options} 637s 637s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 637s Back-end data type applied to the resultant :class:`DataFrame` 637s (still experimental). Behaviour is as follows: 637s 637s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 637s (default). 637s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 637s DataFrame. 637s 637s .. versionadded:: 2.0 637s 637s Returns 637s ------- 637s df 637s A DataFrame. 637s 637s See Also 637s -------- 637s read_json : Convert a JSON string to pandas object. 637s read_html : Read HTML tables into a list of DataFrame objects. 637s 637s Notes 637s ----- 637s This method is best designed to import shallow XML documents in 637s following format which is the ideal fit for the two-dimensions of a 637s ``DataFrame`` (row by column). :: 637s 637s 637s 637s data 637s data 637s data 637s ... 637s 637s 637s ... 637s 637s ... 637s 637s 637s As a file format, XML documents can be designed any way including 637s layout of elements and attributes as long as it conforms to W3C 637s specifications. Therefore, this method is a convenience handler for 637s a specific flatter design and not all possible XML structures. 637s 637s However, for more complex XML documents, ``stylesheet`` allows you to 637s temporarily redesign original document with XSLT (a special purpose 637s language) for a flatter version for migration to a DataFrame. 637s 637s This function will *always* return a single :class:`DataFrame` or raise 637s exceptions due to issues with XML document, ``xpath``, or other 637s parameters. 637s 637s See the :ref:`read_xml documentation in the IO section of the docs 637s ` for more information in using this method to parse XML 637s files to DataFrames. 637s 637s Examples 637s -------- 637s >>> from io import StringIO 637s >>> xml = ''' 637s ... 637s ... 637s ... square 637s ... 360 637s ... 4.0 637s ... 637s ... 637s ... circle 637s ... 360 637s ... 637s ... 637s ... 637s ... triangle 637s ... 180 637s ... 3.0 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml)) 637s >>> df 637s shape degrees sides 637s 0 square 360 4.0 637s 1 circle 360 NaN 637s 2 triangle 180 3.0 637s 637s >>> xml = ''' 637s ... 637s ... 637s ... 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml), xpath=".//row") 637s >>> df 637s shape degrees sides 637s 0 square 360 4.0 637s 1 circle 360 NaN 637s 2 triangle 180 3.0 637s 637s >>> xml = ''' 637s ... 637s ... 637s ... square 637s ... 360 637s ... 4.0 637s ... 637s ... 637s ... circle 637s ... 360 637s ... 637s ... 637s ... 637s ... triangle 637s ... 180 637s ... 3.0 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml), 637s ... xpath="//doc:row", 637s ... namespaces={{"doc": "https://example.com"}}) 637s >>> df 637s shape degrees sides 637s 0 square 360 4.0 637s 1 circle 360 NaN 637s 2 triangle 180 3.0 637s 637s >>> xml_data = ''' 637s ... 637s ... 637s ... 0 637s ... 1 637s ... 2.5 637s ... True 637s ... a 637s ... 2019-12-31 00:00:00 637s ... 637s ... 637s ... 1 637s ... 4.5 637s ... False 637s ... b 637s ... 2019-12-31 00:00:00 637s ... 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml_data), 637s ... dtype_backend="numpy_nullable", 637s ... parse_dates=["e"]) 637s >>> df 637s index a b c d e 637s 0 0 1 2.5 True a 2019-12-31 637s 1 1 4.5 False b 2019-12-31 637s """ 637s check_dtype_backend(dtype_backend) 637s 637s > return _parse( 637s path_or_buffer=path_or_buffer, 637s xpath=xpath, 637s namespaces=namespaces, 637s elems_only=elems_only, 637s attrs_only=attrs_only, 637s names=names, 637s dtype=dtype, 637s converters=converters, 637s parse_dates=parse_dates, 637s encoding=encoding, 637s parser=parser, 637s stylesheet=stylesheet, 637s iterparse=iterparse, 637s compression=compression, 637s storage_options=storage_options, 637s dtype_backend=dtype_backend, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:1160: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buffer = 'http://127.0.0.1:40807', xpath = './/book[count(*)=4]' 637s namespaces = None, elems_only = False, attrs_only = False, names = None 637s dtype = None, converters = None, parse_dates = None, encoding = 'utf-8' 637s parser = 'lxml', stylesheet = None, iterparse = None, compression = 'infer' 637s storage_options = None, dtype_backend = , kwargs = {} 637s lxml = 637s p = 637s 637s def _parse( 637s path_or_buffer: FilePath | ReadBuffer[bytes] | ReadBuffer[str], 637s xpath: str, 637s namespaces: dict[str, str] | None, 637s elems_only: bool, 637s attrs_only: bool, 637s names: Sequence[str] | None, 637s dtype: DtypeArg | None, 637s converters: ConvertersArg | None, 637s parse_dates: ParseDatesArg | None, 637s encoding: str | None, 637s parser: XMLParsers, 637s stylesheet: FilePath | ReadBuffer[bytes] | ReadBuffer[str] | None, 637s iterparse: dict[str, list[str]] | None, 637s compression: CompressionOptions, 637s storage_options: StorageOptions, 637s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 637s **kwargs, 637s ) -> DataFrame: 637s """ 637s Call internal parsers. 637s 637s This method will conditionally call internal parsers: 637s LxmlFrameParser and/or EtreeParser. 637s 637s Raises 637s ------ 637s ImportError 637s * If lxml is not installed if selected as parser. 637s 637s ValueError 637s * If parser is not lxml or etree. 637s """ 637s 637s p: _EtreeFrameParser | _LxmlFrameParser 637s 637s if isinstance(path_or_buffer, str) and not any( 637s [ 637s is_file_like(path_or_buffer), 637s file_exists(path_or_buffer), 637s is_url(path_or_buffer), 637s is_fsspec_url(path_or_buffer), 637s ] 637s ): 637s warnings.warn( 637s "Passing literal xml to 'read_xml' is deprecated and " 637s "will be removed in a future version. To read from a " 637s "literal string, wrap it in a 'StringIO' object.", 637s FutureWarning, 637s stacklevel=find_stack_level(), 637s ) 637s 637s if parser == "lxml": 637s lxml = import_optional_dependency("lxml.etree", errors="ignore") 637s 637s if lxml is not None: 637s p = _LxmlFrameParser( 637s path_or_buffer, 637s xpath, 637s namespaces, 637s elems_only, 637s attrs_only, 637s names, 637s dtype, 637s converters, 637s parse_dates, 637s encoding, 637s stylesheet, 637s iterparse, 637s compression, 637s storage_options, 637s ) 637s else: 637s raise ImportError("lxml not found, please install or use the etree parser.") 637s 637s elif parser == "etree": 637s p = _EtreeFrameParser( 637s path_or_buffer, 637s xpath, 637s namespaces, 637s elems_only, 637s attrs_only, 637s names, 637s dtype, 637s converters, 637s parse_dates, 637s encoding, 637s stylesheet, 637s iterparse, 637s compression, 637s storage_options, 637s ) 637s else: 637s raise ValueError("Values for parser can only be lxml or etree.") 637s 637s > data_dicts = p.parse_data() 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:852: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s 637s def parse_data(self) -> list[dict[str, str | None]]: 637s """ 637s Parse xml data. 637s 637s This method will call the other internal methods to 637s validate ``xpath``, names, optionally parse and run XSLT, 637s and parse original or transformed XML and return specific nodes. 637s """ 637s from lxml.etree import iterparse 637s 637s if self.iterparse is None: 637s > self.xml_doc = self._parse_doc(self.path_or_buffer) 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:556: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s raw_doc = 'http://127.0.0.1:40807' 637s 637s def _parse_doc( 637s self, raw_doc: FilePath | ReadBuffer[bytes] | ReadBuffer[str] 637s ) -> etree._Element: 637s from lxml.etree import ( 637s XMLParser, 637s fromstring, 637s parse, 637s ) 637s 637s > handle_data = get_data_from_filepath( 637s filepath_or_buffer=raw_doc, 637s encoding=self.encoding, 637s compression=self.compression, 637s storage_options=self.storage_options, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:631: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s filepath_or_buffer = 'http://127.0.0.1:40807', encoding = 'utf-8' 637s compression = 'infer', storage_options = None 637s 637s def get_data_from_filepath( 637s filepath_or_buffer: FilePath | bytes | ReadBuffer[bytes] | ReadBuffer[str], 637s encoding: str | None, 637s compression: CompressionOptions, 637s storage_options: StorageOptions, 637s ) -> str | bytes | ReadBuffer[bytes] | ReadBuffer[str]: 637s """ 637s Extract raw XML data. 637s 637s The method accepts three input types: 637s 1. filepath (string-like) 637s 2. file-like object (e.g. open file object, StringIO) 637s 3. XML string or bytes 637s 637s This method turns (1) into (2) to simplify the rest of the processing. 637s It returns input types (2) and (3) unchanged. 637s """ 637s if not isinstance(filepath_or_buffer, bytes): 637s filepath_or_buffer = stringify_path(filepath_or_buffer) 637s 637s if ( 637s isinstance(filepath_or_buffer, str) 637s and not filepath_or_buffer.startswith((" with get_handle( 637s filepath_or_buffer, 637s "r", 637s encoding=encoding, 637s compression=compression, 637s storage_options=storage_options, 637s ) as handle_obj: 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:700: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buf = 'http://127.0.0.1:40807', mode = 'r' 637s 637s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 637s def get_handle( 637s path_or_buf: FilePath | BaseBuffer, 637s mode: str, 637s *, 637s encoding: str | None = None, 637s compression: CompressionOptions | None = None, 637s memory_map: bool = False, 637s is_text: bool = True, 637s errors: str | None = None, 637s storage_options: StorageOptions | None = None, 637s ) -> IOHandles[str] | IOHandles[bytes]: 637s """ 637s Get file handle for given path/buffer and mode. 637s 637s Parameters 637s ---------- 637s path_or_buf : str or file handle 637s File path or object. 637s mode : str 637s Mode to open path_or_buf with. 637s encoding : str or None 637s Encoding to use. 637s {compression_options} 637s 637s May be a dict with key 'method' as compression mode 637s and other keys as compression options if compression 637s mode is 'zip'. 637s 637s Passing compression options as keys in dict is 637s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s memory_map : bool, default False 637s See parsers._parser_params for more information. Only used by read_csv. 637s is_text : bool, default True 637s Whether the type of the content passed to the file/buffer is string or 637s bytes. This is not the same as `"b" not in mode`. If a string content is 637s passed to a binary file/buffer, a wrapper is inserted. 637s errors : str, default 'strict' 637s Specifies how encoding and decoding errors are to be handled. 637s See the errors argument for :func:`open` for a full list 637s of options. 637s storage_options: StorageOptions = None 637s Passed to _get_filepath_or_buffer 637s 637s Returns the dataclass IOHandles 637s """ 637s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 637s encoding = encoding or "utf-8" 637s 637s errors = errors or "strict" 637s 637s # read_csv does not know whether the buffer is opened in binary/text mode 637s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 637s mode += "b" 637s 637s # validate encoding and errors 637s codecs.lookup(encoding) 637s if isinstance(errors, str): 637s codecs.lookup_error(errors) 637s 637s # open URLs 637s > ioargs = _get_filepath_or_buffer( 637s path_or_buf, 637s encoding=encoding, 637s compression=compression, 637s mode=mode, 637s storage_options=storage_options, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s filepath_or_buffer = 'http://127.0.0.1:40807', encoding = 'utf-8' 637s compression = {'method': None}, mode = 'r', storage_options = {} 637s 637s @doc( 637s storage_options=_shared_docs["storage_options"], 637s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 637s ) 637s def _get_filepath_or_buffer( 637s filepath_or_buffer: FilePath | BaseBuffer, 637s encoding: str = "utf-8", 637s compression: CompressionOptions | None = None, 637s mode: str = "r", 637s storage_options: StorageOptions | None = None, 637s ) -> IOArgs: 637s """ 637s If the filepath_or_buffer is a url, translate and return the buffer. 637s Otherwise passthrough. 637s 637s Parameters 637s ---------- 637s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 637s or buffer 637s {compression_options} 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s encoding : the encoding to use to decode bytes, default is 'utf-8' 637s mode : str, optional 637s 637s {storage_options} 637s 637s 637s Returns the dataclass IOArgs. 637s """ 637s filepath_or_buffer = stringify_path(filepath_or_buffer) 637s 637s # handle compression dict 637s compression_method, compression = get_compression_method(compression) 637s compression_method = infer_compression(filepath_or_buffer, compression_method) 637s 637s # GH21227 internal compression is not used for non-binary handles. 637s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 637s warnings.warn( 637s "compression has no effect when passing a non-binary object as input.", 637s RuntimeWarning, 637s stacklevel=find_stack_level(), 637s ) 637s compression_method = None 637s 637s compression = dict(compression, method=compression_method) 637s 637s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 637s # print a warning when writing such files 637s if ( 637s "w" in mode 637s and compression_method in ["bz2", "xz"] 637s and encoding in ["utf-16", "utf-32"] 637s ): 637s warnings.warn( 637s f"{compression} will not write the byte order mark for {encoding}", 637s UnicodeWarning, 637s stacklevel=find_stack_level(), 637s ) 637s 637s # Use binary mode when converting path-like objects to file-like objects (fsspec) 637s # except when text mode is explicitly requested. The original mode is returned if 637s # fsspec is not used. 637s fsspec_mode = mode 637s if "t" not in fsspec_mode and "b" not in fsspec_mode: 637s fsspec_mode += "b" 637s 637s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 637s # TODO: fsspec can also handle HTTP via requests, but leaving this 637s # unchanged. using fsspec appears to break the ability to infer if the 637s # server responded with gzipped data 637s storage_options = storage_options or {} 637s 637s # waiting until now for importing to match intended lazy logic of 637s # urlopen function defined elsewhere in this module 637s import urllib.request 637s 637s # assuming storage_options is to be interpreted as headers 637s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 637s > with urlopen(req_info) as req: 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s args = (,), kwargs = {} 637s urllib = 637s 637s def urlopen(*args, **kwargs): 637s """ 637s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 637s the stdlib. 637s """ 637s import urllib.request 637s 637s > return urllib.request.urlopen(*args, **kwargs) 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s url = , data = None 637s timeout = 637s 637s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 637s *, context=None): 637s '''Open the URL url, which can be either a string or a Request object. 637s 637s *data* must be an object specifying additional data to be sent to 637s the server, or None if no such data is needed. See Request for 637s details. 637s 637s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 637s header in its HTTP requests. 637s 637s The optional *timeout* parameter specifies a timeout in seconds for 637s blocking operations like the connection attempt (if not specified, the 637s global default timeout setting will be used). This only works for HTTP, 637s HTTPS and FTP connections. 637s 637s If *context* is specified, it must be a ssl.SSLContext instance describing 637s the various SSL options. See HTTPSConnection for more details. 637s 637s 637s This function always returns an object which can work as a 637s context manager and has the properties url, headers, and status. 637s See urllib.response.addinfourl for more detail on these properties. 637s 637s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 637s object slightly modified. In addition to the three new methods above, the 637s msg attribute contains the same information as the reason attribute --- 637s the reason phrase returned by the server --- instead of the response 637s headers as it is specified in the documentation for HTTPResponse. 637s 637s For FTP, file, and data URLs and requests explicitly handled by legacy 637s URLopener and FancyURLopener classes, this function returns a 637s urllib.response.addinfourl object. 637s 637s Note that None may be returned if no handler handles the request (though 637s the default installed global OpenerDirector uses UnknownHandler to ensure 637s this never happens). 637s 637s In addition, if proxy settings are detected (for example, when a *_proxy 637s environment variable like http_proxy is set), ProxyHandler is default 637s installed and makes sure the requests are handled through the proxy. 637s 637s ''' 637s global _opener 637s if context: 637s https_handler = HTTPSHandler(context=context) 637s opener = build_opener(https_handler) 637s elif _opener is None: 637s _opener = opener = build_opener() 637s else: 637s opener = _opener 637s > return opener.open(url, data, timeout) 637s 637s /usr/lib/python3.13/urllib/request.py:189: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s fullurl = , data = None 637s timeout = 637s 637s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 637s # accept a URL or a Request object 637s if isinstance(fullurl, str): 637s req = Request(fullurl, data) 637s else: 637s req = fullurl 637s if data is not None: 637s req.data = data 637s 637s req.timeout = timeout 637s protocol = req.type 637s 637s # pre-process request 637s meth_name = protocol+"_request" 637s for processor in self.process_request.get(protocol, []): 637s meth = getattr(processor, meth_name) 637s req = meth(req) 637s 637s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 637s response = self._open(req, data) 637s 637s # post-process response 637s meth_name = protocol+"_response" 637s for processor in self.process_response.get(protocol, []): 637s meth = getattr(processor, meth_name) 637s > response = meth(req, response) 637s 637s /usr/lib/python3.13/urllib/request.py:495: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s request = 637s response = 637s 637s def http_response(self, request, response): 637s code, msg, hdrs = response.code, response.msg, response.info() 637s 637s # According to RFC 2616, "2xx" code indicates that the client's 637s # request was successfully received, understood, and accepted. 637s if not (200 <= code < 300): 637s > response = self.parent.error( 637s 'http', request, response, code, msg, hdrs) 637s 637s /usr/lib/python3.13/urllib/request.py:604: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = , proto = 503 637s args = ({'default': [], 301: [, , 503, ...) 637s dict = {'default': [], 301: [], 303: [], ...} 637s meth_name = 'http_error_503', http_err = 1 637s 637s def error(self, proto, *args): 637s if proto in ('http', 'https'): 637s # XXX http[s] protocols are special-cased 637s dict = self.handle_error['http'] # https is not different than http 637s proto = args[2] # YUCK! 637s meth_name = 'http_error_%s' % proto 637s http_err = 1 637s orig_args = args 637s else: 637s dict = self.handle_error 637s meth_name = proto + '_error' 637s http_err = 0 637s args = (dict, proto, meth_name) + args 637s result = self._call_chain(*args) 637s if result: 637s return result 637s 637s if http_err: 637s args = (dict, 'default', 'http_error_default') + orig_args 637s > return self._call_chain(*args) 637s 637s /usr/lib/python3.13/urllib/request.py:533: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s chain = {'default': [], 301: [], 303: [], ...} 637s kind = 'default', meth_name = 'http_error_default' 637s args = (, , 503, 'Service Unavailable', ) 637s handlers = [] 637s handler = 637s func = > 637s 637s def _call_chain(self, chain, kind, meth_name, *args): 637s # Handlers raise an exception if no one else should try to handle 637s # the request, or return None if they can't but another handler 637s # could. Otherwise, they return the response. 637s handlers = chain.get(kind, ()) 637s for handler in handlers: 637s func = getattr(handler, meth_name) 637s > result = func(*args) 637s 637s /usr/lib/python3.13/urllib/request.py:466: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s req = 637s fp = , code = 503 637s msg = 'Service Unavailable' 637s hdrs = 637s 637s def http_error_default(self, req, fp, code, msg, hdrs): 637s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 637s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 637s 637s /usr/lib/python3.13/urllib/request.py:613: HTTPError 637s _____________________________ test_wrong_url[lxml] _____________________________ 637s 637s parser = 'lxml' 637s httpserver = , started 133469787977408)> 637s 637s @pytest.mark.network 637s @pytest.mark.single_cpu 637s def test_wrong_url(parser, httpserver): 637s httpserver.serve_content("NOT FOUND", code=404) 637s with pytest.raises(HTTPError, match=("HTTP Error 404: NOT FOUND")): 637s > read_xml(httpserver.url, xpath=".//book[count(*)=4]", parser=parser) 637s 637s /usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py:531: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buffer = 'http://127.0.0.1:33349' 637s 637s @doc( 637s storage_options=_shared_docs["storage_options"], 637s decompression_options=_shared_docs["decompression_options"] % "path_or_buffer", 637s ) 637s def read_xml( 637s path_or_buffer: FilePath | ReadBuffer[bytes] | ReadBuffer[str], 637s *, 637s xpath: str = "./*", 637s namespaces: dict[str, str] | None = None, 637s elems_only: bool = False, 637s attrs_only: bool = False, 637s names: Sequence[str] | None = None, 637s dtype: DtypeArg | None = None, 637s converters: ConvertersArg | None = None, 637s parse_dates: ParseDatesArg | None = None, 637s # encoding can not be None for lxml and StringIO input 637s encoding: str | None = "utf-8", 637s parser: XMLParsers = "lxml", 637s stylesheet: FilePath | ReadBuffer[bytes] | ReadBuffer[str] | None = None, 637s iterparse: dict[str, list[str]] | None = None, 637s compression: CompressionOptions = "infer", 637s storage_options: StorageOptions | None = None, 637s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 637s ) -> DataFrame: 637s r""" 637s Read XML document into a :class:`~pandas.DataFrame` object. 637s 637s .. versionadded:: 1.3.0 637s 637s Parameters 637s ---------- 637s path_or_buffer : str, path object, or file-like object 637s String, path object (implementing ``os.PathLike[str]``), or file-like 637s object implementing a ``read()`` function. The string can be any valid XML 637s string or a path. The string can further be a URL. Valid URL schemes 637s include http, ftp, s3, and file. 637s 637s .. deprecated:: 2.1.0 637s Passing xml literal strings is deprecated. 637s Wrap literal xml input in ``io.StringIO`` or ``io.BytesIO`` instead. 637s 637s xpath : str, optional, default './\*' 637s The ``XPath`` to parse required set of nodes for migration to 637s :class:`~pandas.DataFrame`.``XPath`` should return a collection of elements 637s and not a single element. Note: The ``etree`` parser supports limited ``XPath`` 637s expressions. For more complex ``XPath``, use ``lxml`` which requires 637s installation. 637s 637s namespaces : dict, optional 637s The namespaces defined in XML document as dicts with key being 637s namespace prefix and value the URI. There is no need to include all 637s namespaces in XML, only the ones used in ``xpath`` expression. 637s Note: if XML document uses default namespace denoted as 637s `xmlns=''` without a prefix, you must assign any temporary 637s namespace prefix such as 'doc' to the URI in order to parse 637s underlying nodes and/or attributes. For example, :: 637s 637s namespaces = {{"doc": "https://example.com"}} 637s 637s elems_only : bool, optional, default False 637s Parse only the child elements at the specified ``xpath``. By default, 637s all child elements and non-empty text nodes are returned. 637s 637s attrs_only : bool, optional, default False 637s Parse only the attributes at the specified ``xpath``. 637s By default, all attributes are returned. 637s 637s names : list-like, optional 637s Column names for DataFrame of parsed XML data. Use this parameter to 637s rename original element names and distinguish same named elements and 637s attributes. 637s 637s dtype : Type name or dict of column -> type, optional 637s Data type for data or columns. E.g. {{'a': np.float64, 'b': np.int32, 637s 'c': 'Int64'}} 637s Use `str` or `object` together with suitable `na_values` settings 637s to preserve and not interpret dtype. 637s If converters are specified, they will be applied INSTEAD 637s of dtype conversion. 637s 637s .. versionadded:: 1.5.0 637s 637s converters : dict, optional 637s Dict of functions for converting values in certain columns. Keys can either 637s be integers or column labels. 637s 637s .. versionadded:: 1.5.0 637s 637s parse_dates : bool or list of int or names or list of lists or dict, default False 637s Identifiers to parse index or columns to datetime. The behavior is as follows: 637s 637s * boolean. If True -> try parsing the index. 637s * list of int or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3 637s each as a separate date column. 637s * list of lists. e.g. If [[1, 3]] -> combine columns 1 and 3 and parse as 637s a single date column. 637s * dict, e.g. {{'foo' : [1, 3]}} -> parse columns 1, 3 as date and call 637s result 'foo' 637s 637s .. versionadded:: 1.5.0 637s 637s encoding : str, optional, default 'utf-8' 637s Encoding of XML document. 637s 637s parser : {{'lxml','etree'}}, default 'lxml' 637s Parser module to use for retrieval of data. Only 'lxml' and 637s 'etree' are supported. With 'lxml' more complex ``XPath`` searches 637s and ability to use XSLT stylesheet are supported. 637s 637s stylesheet : str, path object or file-like object 637s A URL, file-like object, or a raw string containing an XSLT script. 637s This stylesheet should flatten complex, deeply nested XML documents 637s for easier parsing. To use this feature you must have ``lxml`` module 637s installed and specify 'lxml' as ``parser``. The ``xpath`` must 637s reference nodes of transformed XML document generated after XSLT 637s transformation and not the original XML document. Only XSLT 1.0 637s scripts and not later versions is currently supported. 637s 637s iterparse : dict, optional 637s The nodes or attributes to retrieve in iterparsing of XML document 637s as a dict with key being the name of repeating element and value being 637s list of elements or attribute names that are descendants of the repeated 637s element. Note: If this option is used, it will replace ``xpath`` parsing 637s and unlike ``xpath``, descendants do not need to relate to each other but can 637s exist any where in document under the repeating element. This memory- 637s efficient method should be used for very large XML files (500MB, 1GB, or 5GB+). 637s For example, :: 637s 637s iterparse = {{"row_element": ["child_elem", "attr", "grandchild_elem"]}} 637s 637s .. versionadded:: 1.5.0 637s 637s {decompression_options} 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s {storage_options} 637s 637s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 637s Back-end data type applied to the resultant :class:`DataFrame` 637s (still experimental). Behaviour is as follows: 637s 637s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 637s (default). 637s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 637s DataFrame. 637s 637s .. versionadded:: 2.0 637s 637s Returns 637s ------- 637s df 637s A DataFrame. 637s 637s See Also 637s -------- 637s read_json : Convert a JSON string to pandas object. 637s read_html : Read HTML tables into a list of DataFrame objects. 637s 637s Notes 637s ----- 637s This method is best designed to import shallow XML documents in 637s following format which is the ideal fit for the two-dimensions of a 637s ``DataFrame`` (row by column). :: 637s 637s 637s 637s data 637s data 637s data 637s ... 637s 637s 637s ... 637s 637s ... 637s 637s 637s As a file format, XML documents can be designed any way including 637s layout of elements and attributes as long as it conforms to W3C 637s specifications. Therefore, this method is a convenience handler for 637s a specific flatter design and not all possible XML structures. 637s 637s However, for more complex XML documents, ``stylesheet`` allows you to 637s temporarily redesign original document with XSLT (a special purpose 637s language) for a flatter version for migration to a DataFrame. 637s 637s This function will *always* return a single :class:`DataFrame` or raise 637s exceptions due to issues with XML document, ``xpath``, or other 637s parameters. 637s 637s See the :ref:`read_xml documentation in the IO section of the docs 637s ` for more information in using this method to parse XML 637s files to DataFrames. 637s 637s Examples 637s -------- 637s >>> from io import StringIO 637s >>> xml = ''' 637s ... 637s ... 637s ... square 637s ... 360 637s ... 4.0 637s ... 637s ... 637s ... circle 637s ... 360 637s ... 637s ... 637s ... 637s ... triangle 637s ... 180 637s ... 3.0 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml)) 637s >>> df 637s shape degrees sides 637s 0 square 360 4.0 637s 1 circle 360 NaN 637s 2 triangle 180 3.0 637s 637s >>> xml = ''' 637s ... 637s ... 637s ... 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml), xpath=".//row") 637s >>> df 637s shape degrees sides 637s 0 square 360 4.0 637s 1 circle 360 NaN 637s 2 triangle 180 3.0 637s 637s >>> xml = ''' 637s ... 637s ... 637s ... square 637s ... 360 637s ... 4.0 637s ... 637s ... 637s ... circle 637s ... 360 637s ... 637s ... 637s ... 637s ... triangle 637s ... 180 637s ... 3.0 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml), 637s ... xpath="//doc:row", 637s ... namespaces={{"doc": "https://example.com"}}) 637s >>> df 637s shape degrees sides 637s 0 square 360 4.0 637s 1 circle 360 NaN 637s 2 triangle 180 3.0 637s 637s >>> xml_data = ''' 637s ... 637s ... 637s ... 0 637s ... 1 637s ... 2.5 637s ... True 637s ... a 637s ... 2019-12-31 00:00:00 637s ... 637s ... 637s ... 1 637s ... 4.5 637s ... False 637s ... b 637s ... 2019-12-31 00:00:00 637s ... 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml_data), 637s ... dtype_backend="numpy_nullable", 637s ... parse_dates=["e"]) 637s >>> df 637s index a b c d e 637s 0 0 1 2.5 True a 2019-12-31 637s 1 1 4.5 False b 2019-12-31 637s """ 637s check_dtype_backend(dtype_backend) 637s 637s > return _parse( 637s path_or_buffer=path_or_buffer, 637s xpath=xpath, 637s namespaces=namespaces, 637s elems_only=elems_only, 637s attrs_only=attrs_only, 637s names=names, 637s dtype=dtype, 637s converters=converters, 637s parse_dates=parse_dates, 637s encoding=encoding, 637s parser=parser, 637s stylesheet=stylesheet, 637s iterparse=iterparse, 637s compression=compression, 637s storage_options=storage_options, 637s dtype_backend=dtype_backend, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:1160: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buffer = 'http://127.0.0.1:33349', xpath = './/book[count(*)=4]' 637s namespaces = None, elems_only = False, attrs_only = False, names = None 637s dtype = None, converters = None, parse_dates = None, encoding = 'utf-8' 637s parser = 'lxml', stylesheet = None, iterparse = None, compression = 'infer' 637s storage_options = None, dtype_backend = , kwargs = {} 637s lxml = 637s p = 637s 637s def _parse( 637s path_or_buffer: FilePath | ReadBuffer[bytes] | ReadBuffer[str], 637s xpath: str, 637s namespaces: dict[str, str] | None, 637s elems_only: bool, 637s attrs_only: bool, 637s names: Sequence[str] | None, 637s dtype: DtypeArg | None, 637s converters: ConvertersArg | None, 637s parse_dates: ParseDatesArg | None, 637s encoding: str | None, 637s parser: XMLParsers, 637s stylesheet: FilePath | ReadBuffer[bytes] | ReadBuffer[str] | None, 637s iterparse: dict[str, list[str]] | None, 637s compression: CompressionOptions, 637s storage_options: StorageOptions, 637s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 637s **kwargs, 637s ) -> DataFrame: 637s """ 637s Call internal parsers. 637s 637s This method will conditionally call internal parsers: 637s LxmlFrameParser and/or EtreeParser. 637s 637s Raises 637s ------ 637s ImportError 637s * If lxml is not installed if selected as parser. 637s 637s ValueError 637s * If parser is not lxml or etree. 637s """ 637s 637s p: _EtreeFrameParser | _LxmlFrameParser 637s 637s if isinstance(path_or_buffer, str) and not any( 637s [ 637s is_file_like(path_or_buffer), 637s file_exists(path_or_buffer), 637s is_url(path_or_buffer), 637s is_fsspec_url(path_or_buffer), 637s ] 637s ): 637s warnings.warn( 637s "Passing literal xml to 'read_xml' is deprecated and " 637s "will be removed in a future version. To read from a " 637s "literal string, wrap it in a 'StringIO' object.", 637s FutureWarning, 637s stacklevel=find_stack_level(), 637s ) 637s 637s if parser == "lxml": 637s lxml = import_optional_dependency("lxml.etree", errors="ignore") 637s 637s if lxml is not None: 637s p = _LxmlFrameParser( 637s path_or_buffer, 637s xpath, 637s namespaces, 637s elems_only, 637s attrs_only, 637s names, 637s dtype, 637s converters, 637s parse_dates, 637s encoding, 637s stylesheet, 637s iterparse, 637s compression, 637s storage_options, 637s ) 637s else: 637s raise ImportError("lxml not found, please install or use the etree parser.") 637s 637s elif parser == "etree": 637s p = _EtreeFrameParser( 637s path_or_buffer, 637s xpath, 637s namespaces, 637s elems_only, 637s attrs_only, 637s names, 637s dtype, 637s converters, 637s parse_dates, 637s encoding, 637s stylesheet, 637s iterparse, 637s compression, 637s storage_options, 637s ) 637s else: 637s raise ValueError("Values for parser can only be lxml or etree.") 637s 637s > data_dicts = p.parse_data() 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:852: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s 637s def parse_data(self) -> list[dict[str, str | None]]: 637s """ 637s Parse xml data. 637s 637s This method will call the other internal methods to 637s validate ``xpath``, names, optionally parse and run XSLT, 637s and parse original or transformed XML and return specific nodes. 637s """ 637s from lxml.etree import iterparse 637s 637s if self.iterparse is None: 637s > self.xml_doc = self._parse_doc(self.path_or_buffer) 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:556: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s raw_doc = 'http://127.0.0.1:33349' 637s 637s def _parse_doc( 637s self, raw_doc: FilePath | ReadBuffer[bytes] | ReadBuffer[str] 637s ) -> etree._Element: 637s from lxml.etree import ( 637s XMLParser, 637s fromstring, 637s parse, 637s ) 637s 637s > handle_data = get_data_from_filepath( 637s filepath_or_buffer=raw_doc, 637s encoding=self.encoding, 637s compression=self.compression, 637s storage_options=self.storage_options, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:631: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s filepath_or_buffer = 'http://127.0.0.1:33349', encoding = 'utf-8' 637s compression = 'infer', storage_options = None 637s 637s def get_data_from_filepath( 637s filepath_or_buffer: FilePath | bytes | ReadBuffer[bytes] | ReadBuffer[str], 637s encoding: str | None, 637s compression: CompressionOptions, 637s storage_options: StorageOptions, 637s ) -> str | bytes | ReadBuffer[bytes] | ReadBuffer[str]: 637s """ 637s Extract raw XML data. 637s 637s The method accepts three input types: 637s 1. filepath (string-like) 637s 2. file-like object (e.g. open file object, StringIO) 637s 3. XML string or bytes 637s 637s This method turns (1) into (2) to simplify the rest of the processing. 637s It returns input types (2) and (3) unchanged. 637s """ 637s if not isinstance(filepath_or_buffer, bytes): 637s filepath_or_buffer = stringify_path(filepath_or_buffer) 637s 637s if ( 637s isinstance(filepath_or_buffer, str) 637s and not filepath_or_buffer.startswith((" with get_handle( 637s filepath_or_buffer, 637s "r", 637s encoding=encoding, 637s compression=compression, 637s storage_options=storage_options, 637s ) as handle_obj: 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:700: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buf = 'http://127.0.0.1:33349', mode = 'r' 637s 637s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 637s def get_handle( 637s path_or_buf: FilePath | BaseBuffer, 637s mode: str, 637s *, 637s encoding: str | None = None, 637s compression: CompressionOptions | None = None, 637s memory_map: bool = False, 637s is_text: bool = True, 637s errors: str | None = None, 637s storage_options: StorageOptions | None = None, 637s ) -> IOHandles[str] | IOHandles[bytes]: 637s """ 637s Get file handle for given path/buffer and mode. 637s 637s Parameters 637s ---------- 637s path_or_buf : str or file handle 637s File path or object. 637s mode : str 637s Mode to open path_or_buf with. 637s encoding : str or None 637s Encoding to use. 637s {compression_options} 637s 637s May be a dict with key 'method' as compression mode 637s and other keys as compression options if compression 637s mode is 'zip'. 637s 637s Passing compression options as keys in dict is 637s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s memory_map : bool, default False 637s See parsers._parser_params for more information. Only used by read_csv. 637s is_text : bool, default True 637s Whether the type of the content passed to the file/buffer is string or 637s bytes. This is not the same as `"b" not in mode`. If a string content is 637s passed to a binary file/buffer, a wrapper is inserted. 637s errors : str, default 'strict' 637s Specifies how encoding and decoding errors are to be handled. 637s See the errors argument for :func:`open` for a full list 637s of options. 637s storage_options: StorageOptions = None 637s Passed to _get_filepath_or_buffer 637s 637s Returns the dataclass IOHandles 637s """ 637s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 637s encoding = encoding or "utf-8" 637s 637s errors = errors or "strict" 637s 637s # read_csv does not know whether the buffer is opened in binary/text mode 637s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 637s mode += "b" 637s 637s # validate encoding and errors 637s codecs.lookup(encoding) 637s if isinstance(errors, str): 637s codecs.lookup_error(errors) 637s 637s # open URLs 637s > ioargs = _get_filepath_or_buffer( 637s path_or_buf, 637s encoding=encoding, 637s compression=compression, 637s mode=mode, 637s storage_options=storage_options, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s filepath_or_buffer = 'http://127.0.0.1:33349', encoding = 'utf-8' 637s compression = {'method': None}, mode = 'r', storage_options = {} 637s 637s @doc( 637s storage_options=_shared_docs["storage_options"], 637s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 637s ) 637s def _get_filepath_or_buffer( 637s filepath_or_buffer: FilePath | BaseBuffer, 637s encoding: str = "utf-8", 637s compression: CompressionOptions | None = None, 637s mode: str = "r", 637s storage_options: StorageOptions | None = None, 637s ) -> IOArgs: 637s """ 637s If the filepath_or_buffer is a url, translate and return the buffer. 637s Otherwise passthrough. 637s 637s Parameters 637s ---------- 637s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 637s or buffer 637s {compression_options} 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s encoding : the encoding to use to decode bytes, default is 'utf-8' 637s mode : str, optional 637s 637s {storage_options} 637s 637s 637s Returns the dataclass IOArgs. 637s """ 637s filepath_or_buffer = stringify_path(filepath_or_buffer) 637s 637s # handle compression dict 637s compression_method, compression = get_compression_method(compression) 637s compression_method = infer_compression(filepath_or_buffer, compression_method) 637s 637s # GH21227 internal compression is not used for non-binary handles. 637s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 637s warnings.warn( 637s "compression has no effect when passing a non-binary object as input.", 637s RuntimeWarning, 637s stacklevel=find_stack_level(), 637s ) 637s compression_method = None 637s 637s compression = dict(compression, method=compression_method) 637s 637s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 637s # print a warning when writing such files 637s if ( 637s "w" in mode 637s and compression_method in ["bz2", "xz"] 637s and encoding in ["utf-16", "utf-32"] 637s ): 637s warnings.warn( 637s f"{compression} will not write the byte order mark for {encoding}", 637s UnicodeWarning, 637s stacklevel=find_stack_level(), 637s ) 637s 637s # Use binary mode when converting path-like objects to file-like objects (fsspec) 637s # except when text mode is explicitly requested. The original mode is returned if 637s # fsspec is not used. 637s fsspec_mode = mode 637s if "t" not in fsspec_mode and "b" not in fsspec_mode: 637s fsspec_mode += "b" 637s 637s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 637s # TODO: fsspec can also handle HTTP via requests, but leaving this 637s # unchanged. using fsspec appears to break the ability to infer if the 637s # server responded with gzipped data 637s storage_options = storage_options or {} 637s 637s # waiting until now for importing to match intended lazy logic of 637s # urlopen function defined elsewhere in this module 637s import urllib.request 637s 637s # assuming storage_options is to be interpreted as headers 637s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 637s > with urlopen(req_info) as req: 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s args = (,), kwargs = {} 637s urllib = 637s 637s def urlopen(*args, **kwargs): 637s """ 637s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 637s the stdlib. 637s """ 637s import urllib.request 637s 637s > return urllib.request.urlopen(*args, **kwargs) 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s url = , data = None 637s timeout = 637s 637s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 637s *, context=None): 637s '''Open the URL url, which can be either a string or a Request object. 637s 637s *data* must be an object specifying additional data to be sent to 637s the server, or None if no such data is needed. See Request for 637s details. 637s 637s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 637s header in its HTTP requests. 637s 637s The optional *timeout* parameter specifies a timeout in seconds for 637s blocking operations like the connection attempt (if not specified, the 637s global default timeout setting will be used). This only works for HTTP, 637s HTTPS and FTP connections. 637s 637s If *context* is specified, it must be a ssl.SSLContext instance describing 637s the various SSL options. See HTTPSConnection for more details. 637s 637s 637s This function always returns an object which can work as a 637s context manager and has the properties url, headers, and status. 637s See urllib.response.addinfourl for more detail on these properties. 637s 637s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 637s object slightly modified. In addition to the three new methods above, the 637s msg attribute contains the same information as the reason attribute --- 637s the reason phrase returned by the server --- instead of the response 637s headers as it is specified in the documentation for HTTPResponse. 637s 637s For FTP, file, and data URLs and requests explicitly handled by legacy 637s URLopener and FancyURLopener classes, this function returns a 637s urllib.response.addinfourl object. 637s 637s Note that None may be returned if no handler handles the request (though 637s the default installed global OpenerDirector uses UnknownHandler to ensure 637s this never happens). 637s 637s In addition, if proxy settings are detected (for example, when a *_proxy 637s environment variable like http_proxy is set), ProxyHandler is default 637s installed and makes sure the requests are handled through the proxy. 637s 637s ''' 637s global _opener 637s if context: 637s https_handler = HTTPSHandler(context=context) 637s opener = build_opener(https_handler) 637s elif _opener is None: 637s _opener = opener = build_opener() 637s else: 637s opener = _opener 637s > return opener.open(url, data, timeout) 637s 637s /usr/lib/python3.13/urllib/request.py:189: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s fullurl = , data = None 637s timeout = 637s 637s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 637s # accept a URL or a Request object 637s if isinstance(fullurl, str): 637s req = Request(fullurl, data) 637s else: 637s req = fullurl 637s if data is not None: 637s req.data = data 637s 637s req.timeout = timeout 637s protocol = req.type 637s 637s # pre-process request 637s meth_name = protocol+"_request" 637s for processor in self.process_request.get(protocol, []): 637s meth = getattr(processor, meth_name) 637s req = meth(req) 637s 637s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 637s response = self._open(req, data) 637s 637s # post-process response 637s meth_name = protocol+"_response" 637s for processor in self.process_response.get(protocol, []): 637s meth = getattr(processor, meth_name) 637s > response = meth(req, response) 637s 637s /usr/lib/python3.13/urllib/request.py:495: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s request = 637s response = 637s 637s def http_response(self, request, response): 637s code, msg, hdrs = response.code, response.msg, response.info() 637s 637s # According to RFC 2616, "2xx" code indicates that the client's 637s # request was successfully received, understood, and accepted. 637s if not (200 <= code < 300): 637s > response = self.parent.error( 637s 'http', request, response, code, msg, hdrs) 637s 637s /usr/lib/python3.13/urllib/request.py:604: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = , proto = 503 637s args = ({'default': [], 301: [, , 503, ...) 637s dict = {'default': [], 301: [], 303: [], ...} 637s meth_name = 'http_error_503', http_err = 1 637s 637s def error(self, proto, *args): 637s if proto in ('http', 'https'): 637s # XXX http[s] protocols are special-cased 637s dict = self.handle_error['http'] # https is not different than http 637s proto = args[2] # YUCK! 637s meth_name = 'http_error_%s' % proto 637s http_err = 1 637s orig_args = args 637s else: 637s dict = self.handle_error 637s meth_name = proto + '_error' 637s http_err = 0 637s args = (dict, proto, meth_name) + args 637s result = self._call_chain(*args) 637s if result: 637s return result 637s 637s if http_err: 637s args = (dict, 'default', 'http_error_default') + orig_args 637s > return self._call_chain(*args) 637s 637s /usr/lib/python3.13/urllib/request.py:533: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s chain = {'default': [], 301: [], 303: [], ...} 637s kind = 'default', meth_name = 'http_error_default' 637s args = (, , 503, 'Service Unavailable', ) 637s handlers = [] 637s handler = 637s func = > 637s 637s def _call_chain(self, chain, kind, meth_name, *args): 637s # Handlers raise an exception if no one else should try to handle 637s # the request, or return None if they can't but another handler 637s # could. Otherwise, they return the response. 637s handlers = chain.get(kind, ()) 637s for handler in handlers: 637s func = getattr(handler, meth_name) 637s > result = func(*args) 637s 637s /usr/lib/python3.13/urllib/request.py:466: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s req = 637s fp = , code = 503 637s msg = 'Service Unavailable' 637s hdrs = 637s 637s def http_error_default(self, req, fp, code, msg, hdrs): 637s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 637s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 637s 637s /usr/lib/python3.13/urllib/request.py:613: HTTPError 637s 637s During handling of the above exception, another exception occurred: 637s 637s parser = 'lxml' 637s httpserver = , started 133469787977408)> 637s 637s @pytest.mark.network 637s @pytest.mark.single_cpu 637s def test_wrong_url(parser, httpserver): 637s httpserver.serve_content("NOT FOUND", code=404) 637s > with pytest.raises(HTTPError, match=("HTTP Error 404: NOT FOUND")): 637s E AssertionError: Regex pattern did not match. 637s E Regex: 'HTTP Error 404: NOT FOUND' 637s E Input: 'HTTP Error 503: Service Unavailable' 637s 637s /usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py:530: AssertionError 637s ____________________________ test_wrong_url[etree] _____________________________ 637s 637s parser = 'etree' 637s httpserver = , started 133469804762816)> 637s 637s @pytest.mark.network 637s @pytest.mark.single_cpu 637s def test_wrong_url(parser, httpserver): 637s httpserver.serve_content("NOT FOUND", code=404) 637s with pytest.raises(HTTPError, match=("HTTP Error 404: NOT FOUND")): 637s > read_xml(httpserver.url, xpath=".//book[count(*)=4]", parser=parser) 637s 637s /usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py:531: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buffer = 'http://127.0.0.1:43043' 637s 637s @doc( 637s storage_options=_shared_docs["storage_options"], 637s decompression_options=_shared_docs["decompression_options"] % "path_or_buffer", 637s ) 637s def read_xml( 637s path_or_buffer: FilePath | ReadBuffer[bytes] | ReadBuffer[str], 637s *, 637s xpath: str = "./*", 637s namespaces: dict[str, str] | None = None, 637s elems_only: bool = False, 637s attrs_only: bool = False, 637s names: Sequence[str] | None = None, 637s dtype: DtypeArg | None = None, 637s converters: ConvertersArg | None = None, 637s parse_dates: ParseDatesArg | None = None, 637s # encoding can not be None for lxml and StringIO input 637s encoding: str | None = "utf-8", 637s parser: XMLParsers = "lxml", 637s stylesheet: FilePath | ReadBuffer[bytes] | ReadBuffer[str] | None = None, 637s iterparse: dict[str, list[str]] | None = None, 637s compression: CompressionOptions = "infer", 637s storage_options: StorageOptions | None = None, 637s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 637s ) -> DataFrame: 637s r""" 637s Read XML document into a :class:`~pandas.DataFrame` object. 637s 637s .. versionadded:: 1.3.0 637s 637s Parameters 637s ---------- 637s path_or_buffer : str, path object, or file-like object 637s String, path object (implementing ``os.PathLike[str]``), or file-like 637s object implementing a ``read()`` function. The string can be any valid XML 637s string or a path. The string can further be a URL. Valid URL schemes 637s include http, ftp, s3, and file. 637s 637s .. deprecated:: 2.1.0 637s Passing xml literal strings is deprecated. 637s Wrap literal xml input in ``io.StringIO`` or ``io.BytesIO`` instead. 637s 637s xpath : str, optional, default './\*' 637s The ``XPath`` to parse required set of nodes for migration to 637s :class:`~pandas.DataFrame`.``XPath`` should return a collection of elements 637s and not a single element. Note: The ``etree`` parser supports limited ``XPath`` 637s expressions. For more complex ``XPath``, use ``lxml`` which requires 637s installation. 637s 637s namespaces : dict, optional 637s The namespaces defined in XML document as dicts with key being 637s namespace prefix and value the URI. There is no need to include all 637s namespaces in XML, only the ones used in ``xpath`` expression. 637s Note: if XML document uses default namespace denoted as 637s `xmlns=''` without a prefix, you must assign any temporary 637s namespace prefix such as 'doc' to the URI in order to parse 637s underlying nodes and/or attributes. For example, :: 637s 637s namespaces = {{"doc": "https://example.com"}} 637s 637s elems_only : bool, optional, default False 637s Parse only the child elements at the specified ``xpath``. By default, 637s all child elements and non-empty text nodes are returned. 637s 637s attrs_only : bool, optional, default False 637s Parse only the attributes at the specified ``xpath``. 637s By default, all attributes are returned. 637s 637s names : list-like, optional 637s Column names for DataFrame of parsed XML data. Use this parameter to 637s rename original element names and distinguish same named elements and 637s attributes. 637s 637s dtype : Type name or dict of column -> type, optional 637s Data type for data or columns. E.g. {{'a': np.float64, 'b': np.int32, 637s 'c': 'Int64'}} 637s Use `str` or `object` together with suitable `na_values` settings 637s to preserve and not interpret dtype. 637s If converters are specified, they will be applied INSTEAD 637s of dtype conversion. 637s 637s .. versionadded:: 1.5.0 637s 637s converters : dict, optional 637s Dict of functions for converting values in certain columns. Keys can either 637s be integers or column labels. 637s 637s .. versionadded:: 1.5.0 637s 637s parse_dates : bool or list of int or names or list of lists or dict, default False 637s Identifiers to parse index or columns to datetime. The behavior is as follows: 637s 637s * boolean. If True -> try parsing the index. 637s * list of int or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3 637s each as a separate date column. 637s * list of lists. e.g. If [[1, 3]] -> combine columns 1 and 3 and parse as 637s a single date column. 637s * dict, e.g. {{'foo' : [1, 3]}} -> parse columns 1, 3 as date and call 637s result 'foo' 637s 637s .. versionadded:: 1.5.0 637s 637s encoding : str, optional, default 'utf-8' 637s Encoding of XML document. 637s 637s parser : {{'lxml','etree'}}, default 'lxml' 637s Parser module to use for retrieval of data. Only 'lxml' and 637s 'etree' are supported. With 'lxml' more complex ``XPath`` searches 637s and ability to use XSLT stylesheet are supported. 637s 637s stylesheet : str, path object or file-like object 637s A URL, file-like object, or a raw string containing an XSLT script. 637s This stylesheet should flatten complex, deeply nested XML documents 637s for easier parsing. To use this feature you must have ``lxml`` module 637s installed and specify 'lxml' as ``parser``. The ``xpath`` must 637s reference nodes of transformed XML document generated after XSLT 637s transformation and not the original XML document. Only XSLT 1.0 637s scripts and not later versions is currently supported. 637s 637s iterparse : dict, optional 637s The nodes or attributes to retrieve in iterparsing of XML document 637s as a dict with key being the name of repeating element and value being 637s list of elements or attribute names that are descendants of the repeated 637s element. Note: If this option is used, it will replace ``xpath`` parsing 637s and unlike ``xpath``, descendants do not need to relate to each other but can 637s exist any where in document under the repeating element. This memory- 637s efficient method should be used for very large XML files (500MB, 1GB, or 5GB+). 637s For example, :: 637s 637s iterparse = {{"row_element": ["child_elem", "attr", "grandchild_elem"]}} 637s 637s .. versionadded:: 1.5.0 637s 637s {decompression_options} 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s {storage_options} 637s 637s dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' 637s Back-end data type applied to the resultant :class:`DataFrame` 637s (still experimental). Behaviour is as follows: 637s 637s * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame` 637s (default). 637s * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype` 637s DataFrame. 637s 637s .. versionadded:: 2.0 637s 637s Returns 637s ------- 637s df 637s A DataFrame. 637s 637s See Also 637s -------- 637s read_json : Convert a JSON string to pandas object. 637s read_html : Read HTML tables into a list of DataFrame objects. 637s 637s Notes 637s ----- 637s This method is best designed to import shallow XML documents in 637s following format which is the ideal fit for the two-dimensions of a 637s ``DataFrame`` (row by column). :: 637s 637s 637s 637s data 637s data 637s data 637s ... 637s 637s 637s ... 637s 637s ... 637s 637s 637s As a file format, XML documents can be designed any way including 637s layout of elements and attributes as long as it conforms to W3C 637s specifications. Therefore, this method is a convenience handler for 637s a specific flatter design and not all possible XML structures. 637s 637s However, for more complex XML documents, ``stylesheet`` allows you to 637s temporarily redesign original document with XSLT (a special purpose 637s language) for a flatter version for migration to a DataFrame. 637s 637s This function will *always* return a single :class:`DataFrame` or raise 637s exceptions due to issues with XML document, ``xpath``, or other 637s parameters. 637s 637s See the :ref:`read_xml documentation in the IO section of the docs 637s ` for more information in using this method to parse XML 637s files to DataFrames. 637s 637s Examples 637s -------- 637s >>> from io import StringIO 637s >>> xml = ''' 637s ... 637s ... 637s ... square 637s ... 360 637s ... 4.0 637s ... 637s ... 637s ... circle 637s ... 360 637s ... 637s ... 637s ... 637s ... triangle 637s ... 180 637s ... 3.0 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml)) 637s >>> df 637s shape degrees sides 637s 0 square 360 4.0 637s 1 circle 360 NaN 637s 2 triangle 180 3.0 637s 637s >>> xml = ''' 637s ... 637s ... 637s ... 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml), xpath=".//row") 637s >>> df 637s shape degrees sides 637s 0 square 360 4.0 637s 1 circle 360 NaN 637s 2 triangle 180 3.0 637s 637s >>> xml = ''' 637s ... 637s ... 637s ... square 637s ... 360 637s ... 4.0 637s ... 637s ... 637s ... circle 637s ... 360 637s ... 637s ... 637s ... 637s ... triangle 637s ... 180 637s ... 3.0 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml), 637s ... xpath="//doc:row", 637s ... namespaces={{"doc": "https://example.com"}}) 637s >>> df 637s shape degrees sides 637s 0 square 360 4.0 637s 1 circle 360 NaN 637s 2 triangle 180 3.0 637s 637s >>> xml_data = ''' 637s ... 637s ... 637s ... 0 637s ... 1 637s ... 2.5 637s ... True 637s ... a 637s ... 2019-12-31 00:00:00 637s ... 637s ... 637s ... 1 637s ... 4.5 637s ... False 637s ... b 637s ... 2019-12-31 00:00:00 637s ... 637s ... 637s ... ''' 637s 637s >>> df = pd.read_xml(StringIO(xml_data), 637s ... dtype_backend="numpy_nullable", 637s ... parse_dates=["e"]) 637s >>> df 637s index a b c d e 637s 0 0 1 2.5 True a 2019-12-31 637s 1 1 4.5 False b 2019-12-31 637s """ 637s check_dtype_backend(dtype_backend) 637s 637s > return _parse( 637s path_or_buffer=path_or_buffer, 637s xpath=xpath, 637s namespaces=namespaces, 637s elems_only=elems_only, 637s attrs_only=attrs_only, 637s names=names, 637s dtype=dtype, 637s converters=converters, 637s parse_dates=parse_dates, 637s encoding=encoding, 637s parser=parser, 637s stylesheet=stylesheet, 637s iterparse=iterparse, 637s compression=compression, 637s storage_options=storage_options, 637s dtype_backend=dtype_backend, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:1160: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buffer = 'http://127.0.0.1:43043', xpath = './/book[count(*)=4]' 637s namespaces = None, elems_only = False, attrs_only = False, names = None 637s dtype = None, converters = None, parse_dates = None, encoding = 'utf-8' 637s parser = 'etree', stylesheet = None, iterparse = None, compression = 'infer' 637s storage_options = None, dtype_backend = , kwargs = {} 637s p = 637s 637s def _parse( 637s path_or_buffer: FilePath | ReadBuffer[bytes] | ReadBuffer[str], 637s xpath: str, 637s namespaces: dict[str, str] | None, 637s elems_only: bool, 637s attrs_only: bool, 637s names: Sequence[str] | None, 637s dtype: DtypeArg | None, 637s converters: ConvertersArg | None, 637s parse_dates: ParseDatesArg | None, 637s encoding: str | None, 637s parser: XMLParsers, 637s stylesheet: FilePath | ReadBuffer[bytes] | ReadBuffer[str] | None, 637s iterparse: dict[str, list[str]] | None, 637s compression: CompressionOptions, 637s storage_options: StorageOptions, 637s dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default, 637s **kwargs, 637s ) -> DataFrame: 637s """ 637s Call internal parsers. 637s 637s This method will conditionally call internal parsers: 637s LxmlFrameParser and/or EtreeParser. 637s 637s Raises 637s ------ 637s ImportError 637s * If lxml is not installed if selected as parser. 637s 637s ValueError 637s * If parser is not lxml or etree. 637s """ 637s 637s p: _EtreeFrameParser | _LxmlFrameParser 637s 637s if isinstance(path_or_buffer, str) and not any( 637s [ 637s is_file_like(path_or_buffer), 637s file_exists(path_or_buffer), 637s is_url(path_or_buffer), 637s is_fsspec_url(path_or_buffer), 637s ] 637s ): 637s warnings.warn( 637s "Passing literal xml to 'read_xml' is deprecated and " 637s "will be removed in a future version. To read from a " 637s "literal string, wrap it in a 'StringIO' object.", 637s FutureWarning, 637s stacklevel=find_stack_level(), 637s ) 637s 637s if parser == "lxml": 637s lxml = import_optional_dependency("lxml.etree", errors="ignore") 637s 637s if lxml is not None: 637s p = _LxmlFrameParser( 637s path_or_buffer, 637s xpath, 637s namespaces, 637s elems_only, 637s attrs_only, 637s names, 637s dtype, 637s converters, 637s parse_dates, 637s encoding, 637s stylesheet, 637s iterparse, 637s compression, 637s storage_options, 637s ) 637s else: 637s raise ImportError("lxml not found, please install or use the etree parser.") 637s 637s elif parser == "etree": 637s p = _EtreeFrameParser( 637s path_or_buffer, 637s xpath, 637s namespaces, 637s elems_only, 637s attrs_only, 637s names, 637s dtype, 637s converters, 637s parse_dates, 637s encoding, 637s stylesheet, 637s iterparse, 637s compression, 637s storage_options, 637s ) 637s else: 637s raise ValueError("Values for parser can only be lxml or etree.") 637s 637s > data_dicts = p.parse_data() 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:852: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s 637s def parse_data(self) -> list[dict[str, str | None]]: 637s from xml.etree.ElementTree import iterparse 637s 637s if self.stylesheet is not None: 637s raise ValueError( 637s "To use stylesheet, you need lxml installed and selected as parser." 637s ) 637s 637s if self.iterparse is None: 637s > self.xml_doc = self._parse_doc(self.path_or_buffer) 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:442: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s raw_doc = 'http://127.0.0.1:43043' 637s 637s def _parse_doc( 637s self, raw_doc: FilePath | ReadBuffer[bytes] | ReadBuffer[str] 637s ) -> Element: 637s from xml.etree.ElementTree import ( 637s XMLParser, 637s parse, 637s ) 637s 637s > handle_data = get_data_from_filepath( 637s filepath_or_buffer=raw_doc, 637s encoding=self.encoding, 637s compression=self.compression, 637s storage_options=self.storage_options, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:524: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s filepath_or_buffer = 'http://127.0.0.1:43043', encoding = 'utf-8' 637s compression = 'infer', storage_options = None 637s 637s def get_data_from_filepath( 637s filepath_or_buffer: FilePath | bytes | ReadBuffer[bytes] | ReadBuffer[str], 637s encoding: str | None, 637s compression: CompressionOptions, 637s storage_options: StorageOptions, 637s ) -> str | bytes | ReadBuffer[bytes] | ReadBuffer[str]: 637s """ 637s Extract raw XML data. 637s 637s The method accepts three input types: 637s 1. filepath (string-like) 637s 2. file-like object (e.g. open file object, StringIO) 637s 3. XML string or bytes 637s 637s This method turns (1) into (2) to simplify the rest of the processing. 637s It returns input types (2) and (3) unchanged. 637s """ 637s if not isinstance(filepath_or_buffer, bytes): 637s filepath_or_buffer = stringify_path(filepath_or_buffer) 637s 637s if ( 637s isinstance(filepath_or_buffer, str) 637s and not filepath_or_buffer.startswith((" with get_handle( 637s filepath_or_buffer, 637s "r", 637s encoding=encoding, 637s compression=compression, 637s storage_options=storage_options, 637s ) as handle_obj: 637s 637s /usr/lib/python3/dist-packages/pandas/io/xml.py:700: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s path_or_buf = 'http://127.0.0.1:43043', mode = 'r' 637s 637s @doc(compression_options=_shared_docs["compression_options"] % "path_or_buf") 637s def get_handle( 637s path_or_buf: FilePath | BaseBuffer, 637s mode: str, 637s *, 637s encoding: str | None = None, 637s compression: CompressionOptions | None = None, 637s memory_map: bool = False, 637s is_text: bool = True, 637s errors: str | None = None, 637s storage_options: StorageOptions | None = None, 637s ) -> IOHandles[str] | IOHandles[bytes]: 637s """ 637s Get file handle for given path/buffer and mode. 637s 637s Parameters 637s ---------- 637s path_or_buf : str or file handle 637s File path or object. 637s mode : str 637s Mode to open path_or_buf with. 637s encoding : str or None 637s Encoding to use. 637s {compression_options} 637s 637s May be a dict with key 'method' as compression mode 637s and other keys as compression options if compression 637s mode is 'zip'. 637s 637s Passing compression options as keys in dict is 637s supported for compression modes 'gzip', 'bz2', 'zstd' and 'zip'. 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s memory_map : bool, default False 637s See parsers._parser_params for more information. Only used by read_csv. 637s is_text : bool, default True 637s Whether the type of the content passed to the file/buffer is string or 637s bytes. This is not the same as `"b" not in mode`. If a string content is 637s passed to a binary file/buffer, a wrapper is inserted. 637s errors : str, default 'strict' 637s Specifies how encoding and decoding errors are to be handled. 637s See the errors argument for :func:`open` for a full list 637s of options. 637s storage_options: StorageOptions = None 637s Passed to _get_filepath_or_buffer 637s 637s Returns the dataclass IOHandles 637s """ 637s # Windows does not default to utf-8. Set to utf-8 for a consistent behavior 637s encoding = encoding or "utf-8" 637s 637s errors = errors or "strict" 637s 637s # read_csv does not know whether the buffer is opened in binary/text mode 637s if _is_binary_mode(path_or_buf, mode) and "b" not in mode: 637s mode += "b" 637s 637s # validate encoding and errors 637s codecs.lookup(encoding) 637s if isinstance(errors, str): 637s codecs.lookup_error(errors) 637s 637s # open URLs 637s > ioargs = _get_filepath_or_buffer( 637s path_or_buf, 637s encoding=encoding, 637s compression=compression, 637s mode=mode, 637s storage_options=storage_options, 637s ) 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:728: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s filepath_or_buffer = 'http://127.0.0.1:43043', encoding = 'utf-8' 637s compression = {'method': None}, mode = 'r', storage_options = {} 637s 637s @doc( 637s storage_options=_shared_docs["storage_options"], 637s compression_options=_shared_docs["compression_options"] % "filepath_or_buffer", 637s ) 637s def _get_filepath_or_buffer( 637s filepath_or_buffer: FilePath | BaseBuffer, 637s encoding: str = "utf-8", 637s compression: CompressionOptions | None = None, 637s mode: str = "r", 637s storage_options: StorageOptions | None = None, 637s ) -> IOArgs: 637s """ 637s If the filepath_or_buffer is a url, translate and return the buffer. 637s Otherwise passthrough. 637s 637s Parameters 637s ---------- 637s filepath_or_buffer : a url, filepath (str, py.path.local or pathlib.Path), 637s or buffer 637s {compression_options} 637s 637s .. versionchanged:: 1.4.0 Zstandard support. 637s 637s encoding : the encoding to use to decode bytes, default is 'utf-8' 637s mode : str, optional 637s 637s {storage_options} 637s 637s 637s Returns the dataclass IOArgs. 637s """ 637s filepath_or_buffer = stringify_path(filepath_or_buffer) 637s 637s # handle compression dict 637s compression_method, compression = get_compression_method(compression) 637s compression_method = infer_compression(filepath_or_buffer, compression_method) 637s 637s # GH21227 internal compression is not used for non-binary handles. 637s if compression_method and hasattr(filepath_or_buffer, "write") and "b" not in mode: 637s warnings.warn( 637s "compression has no effect when passing a non-binary object as input.", 637s RuntimeWarning, 637s stacklevel=find_stack_level(), 637s ) 637s compression_method = None 637s 637s compression = dict(compression, method=compression_method) 637s 637s # bz2 and xz do not write the byte order mark for utf-16 and utf-32 637s # print a warning when writing such files 637s if ( 637s "w" in mode 637s and compression_method in ["bz2", "xz"] 637s and encoding in ["utf-16", "utf-32"] 637s ): 637s warnings.warn( 637s f"{compression} will not write the byte order mark for {encoding}", 637s UnicodeWarning, 637s stacklevel=find_stack_level(), 637s ) 637s 637s # Use binary mode when converting path-like objects to file-like objects (fsspec) 637s # except when text mode is explicitly requested. The original mode is returned if 637s # fsspec is not used. 637s fsspec_mode = mode 637s if "t" not in fsspec_mode and "b" not in fsspec_mode: 637s fsspec_mode += "b" 637s 637s if isinstance(filepath_or_buffer, str) and is_url(filepath_or_buffer): 637s # TODO: fsspec can also handle HTTP via requests, but leaving this 637s # unchanged. using fsspec appears to break the ability to infer if the 637s # server responded with gzipped data 637s storage_options = storage_options or {} 637s 637s # waiting until now for importing to match intended lazy logic of 637s # urlopen function defined elsewhere in this module 637s import urllib.request 637s 637s # assuming storage_options is to be interpreted as headers 637s req_info = urllib.request.Request(filepath_or_buffer, headers=storage_options) 637s > with urlopen(req_info) as req: 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:384: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s args = (,), kwargs = {} 637s urllib = 637s 637s def urlopen(*args, **kwargs): 637s """ 637s Lazy-import wrapper for stdlib urlopen, as that imports a big chunk of 637s the stdlib. 637s """ 637s import urllib.request 637s 637s > return urllib.request.urlopen(*args, **kwargs) 637s 637s /usr/lib/python3/dist-packages/pandas/io/common.py:289: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s url = , data = None 637s timeout = 637s 637s def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, 637s *, context=None): 637s '''Open the URL url, which can be either a string or a Request object. 637s 637s *data* must be an object specifying additional data to be sent to 637s the server, or None if no such data is needed. See Request for 637s details. 637s 637s urllib.request module uses HTTP/1.1 and includes a "Connection:close" 637s header in its HTTP requests. 637s 637s The optional *timeout* parameter specifies a timeout in seconds for 637s blocking operations like the connection attempt (if not specified, the 637s global default timeout setting will be used). This only works for HTTP, 637s HTTPS and FTP connections. 637s 637s If *context* is specified, it must be a ssl.SSLContext instance describing 637s the various SSL options. See HTTPSConnection for more details. 637s 637s 637s This function always returns an object which can work as a 637s context manager and has the properties url, headers, and status. 637s See urllib.response.addinfourl for more detail on these properties. 637s 637s For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse 637s object slightly modified. In addition to the three new methods above, the 637s msg attribute contains the same information as the reason attribute --- 637s the reason phrase returned by the server --- instead of the response 637s headers as it is specified in the documentation for HTTPResponse. 637s 637s For FTP, file, and data URLs and requests explicitly handled by legacy 637s URLopener and FancyURLopener classes, this function returns a 637s urllib.response.addinfourl object. 637s 637s Note that None may be returned if no handler handles the request (though 637s the default installed global OpenerDirector uses UnknownHandler to ensure 637s this never happens). 637s 637s In addition, if proxy settings are detected (for example, when a *_proxy 637s environment variable like http_proxy is set), ProxyHandler is default 637s installed and makes sure the requests are handled through the proxy. 637s 637s ''' 637s global _opener 637s if context: 637s https_handler = HTTPSHandler(context=context) 637s opener = build_opener(https_handler) 637s elif _opener is None: 637s _opener = opener = build_opener() 637s else: 637s opener = _opener 637s > return opener.open(url, data, timeout) 637s 637s /usr/lib/python3.13/urllib/request.py:189: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s fullurl = , data = None 637s timeout = 637s 637s def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): 637s # accept a URL or a Request object 637s if isinstance(fullurl, str): 637s req = Request(fullurl, data) 637s else: 637s req = fullurl 637s if data is not None: 637s req.data = data 637s 637s req.timeout = timeout 637s protocol = req.type 637s 637s # pre-process request 637s meth_name = protocol+"_request" 637s for processor in self.process_request.get(protocol, []): 637s meth = getattr(processor, meth_name) 637s req = meth(req) 637s 637s sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) 637s response = self._open(req, data) 637s 637s # post-process response 637s meth_name = protocol+"_response" 637s for processor in self.process_response.get(protocol, []): 637s meth = getattr(processor, meth_name) 637s > response = meth(req, response) 637s 637s /usr/lib/python3.13/urllib/request.py:495: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s request = 637s response = 637s 637s def http_response(self, request, response): 637s code, msg, hdrs = response.code, response.msg, response.info() 637s 637s # According to RFC 2616, "2xx" code indicates that the client's 637s # request was successfully received, understood, and accepted. 637s if not (200 <= code < 300): 637s > response = self.parent.error( 637s 'http', request, response, code, msg, hdrs) 637s 637s /usr/lib/python3.13/urllib/request.py:604: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = , proto = 503 637s args = ({'default': [], 301: [, , 503, ...) 637s dict = {'default': [], 301: [], 303: [], ...} 637s meth_name = 'http_error_503', http_err = 1 637s 637s def error(self, proto, *args): 637s if proto in ('http', 'https'): 637s # XXX http[s] protocols are special-cased 637s dict = self.handle_error['http'] # https is not different than http 637s proto = args[2] # YUCK! 637s meth_name = 'http_error_%s' % proto 637s http_err = 1 637s orig_args = args 637s else: 637s dict = self.handle_error 637s meth_name = proto + '_error' 637s http_err = 0 637s args = (dict, proto, meth_name) + args 637s result = self._call_chain(*args) 637s if result: 637s return result 637s 637s if http_err: 637s args = (dict, 'default', 'http_error_default') + orig_args 637s > return self._call_chain(*args) 637s 637s /usr/lib/python3.13/urllib/request.py:533: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s chain = {'default': [], 301: [], 303: [], ...} 637s kind = 'default', meth_name = 'http_error_default' 637s args = (, , 503, 'Service Unavailable', ) 637s handlers = [] 637s handler = 637s func = > 637s 637s def _call_chain(self, chain, kind, meth_name, *args): 637s # Handlers raise an exception if no one else should try to handle 637s # the request, or return None if they can't but another handler 637s # could. Otherwise, they return the response. 637s handlers = chain.get(kind, ()) 637s for handler in handlers: 637s func = getattr(handler, meth_name) 637s > result = func(*args) 637s 637s /usr/lib/python3.13/urllib/request.py:466: 637s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 637s 637s self = 637s req = 637s fp = , code = 503 637s msg = 'Service Unavailable' 637s hdrs = 637s 637s def http_error_default(self, req, fp, code, msg, hdrs): 637s > raise HTTPError(req.full_url, code, msg, hdrs, fp) 637s E urllib.error.HTTPError: HTTP Error 503: Service Unavailable 637s 637s /usr/lib/python3.13/urllib/request.py:613: HTTPError 637s 637s During handling of the above exception, another exception occurred: 637s 637s parser = 'etree' 637s httpserver = , started 133469804762816)> 637s 637s @pytest.mark.network 637s @pytest.mark.single_cpu 637s def test_wrong_url(parser, httpserver): 637s httpserver.serve_content("NOT FOUND", code=404) 637s > with pytest.raises(HTTPError, match=("HTTP Error 404: NOT FOUND")): 637s E AssertionError: Regex pattern did not match. 637s E Regex: 'HTTP Error 404: NOT FOUND' 637s E Input: 'HTTP Error 503: Service Unavailable' 637s 637s /usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py:530: AssertionError 637s =============================== warnings summary =============================== 637s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 637s /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-edp7kt6w' 637s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 637s 637s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 637s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/.pytest_cache/v/cache/lastfailed: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/pytest-cache-files-avqcf72p' 637s config.cache.set("cache/lastfailed", self.lastfailed) 637s 637s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 637s /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-nbsilpgy' 637s session.config.cache.set(STEPWISE_CACHE_DIR, []) 637s 637s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 637s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 637s ============================= slowest 30 durations ============================= 637s 1.15s call tests/io/pytables/test_file_handling.py::test_complibs[blosc2-1] 637s 1.01s call tests/io/pytables/test_store.py::test_no_track_times 637s 0.76s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-5] 637s 0.76s call tests/io/test_pickle.py::test_pickle_big_dataframe_compression[gzip-4] 637s 0.50s teardown tests/io/xml/test_xml.py::test_url_path_error[etree] 637s 0.50s teardown tests/io/xml/test_xml.py::test_url_path_error[lxml] 637s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[lxml] 637s 0.50s teardown tests/io/test_html.py::TestReadHtml::test_bad_url_protocol[bs4] 637s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[tar-c-explicit] 637s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[tar-python-explicit] 637s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[tar-c-infer] 637s 0.50s teardown tests/io/parser/test_network.py::test_compressed_urls[tar-python-infer] 637s 0.50s teardown tests/io/xml/test_xml.py::test_parser_consistency_url[lxml] 637s 0.50s teardown tests/io/xml/test_xml.py::test_parser_consistency_url[etree] 637s 0.44s call tests/io/pytables/test_select.py::test_select_iterator_complete_8014 637s 0.42s call tests/io/test_html.py::TestReadHtml::test_banklist_no_match[bs4] 637s 0.38s call tests/io/test_html.py::TestReadHtml::test_displayed_only[lxml-True-exp00-None] 637s 0.37s teardown tests/io/parser/test_read_fwf.py::test_url_urlopen 637s 0.37s teardown tests/io/test_http_headers.py::test_request_headers[None-pickle_respnder-read_pickle] 637s 0.36s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-pickle_respnder-read_pickle] 637s 0.36s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-pickle_respnder-read_pickle] 637s 0.35s call tests/io/parser/test_parse_dates.py::test_bad_date_parse_with_warning[python-0-False] 637s 0.34s teardown tests/io/test_http_headers.py::test_request_headers[None-gz_json_responder-read_json] 637s 0.34s teardown tests/io/test_http_headers.py::test_request_headers[None-html_responder-] 637s 0.34s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-html_responder-] 637s 0.34s call tests/io/test_compression.py::test_with_missing_lzma_runtime 637s 0.34s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-json_responder-read_json] 637s 0.34s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-json_responder-read_json] 637s 0.34s teardown tests/io/test_http_headers.py::test_request_headers[storage_options1-gz_json_responder-read_json] 637s 0.34s teardown tests/io/test_http_headers.py::test_request_headers[storage_options2-gz_json_responder-read_json] 637s =========================== short test summary info ============================ 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py::TestReaders::test_read_from_http_url[('xlrd', '.xls')] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py::TestReaders::test_read_from_http_url[('openpyxl', '.xlsx')] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py::TestReaders::test_read_from_http_url[('openpyxl', '.xlsm')] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py::TestReaders::test_read_from_http_url[(None, '.xls')] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py::TestReaders::test_read_from_http_url[(None, '.xlsx')] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py::TestReaders::test_read_from_http_url[(None, '.xlsm')] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/excel/test_readers.py::TestReaders::test_read_from_http_url[('odf', '.ods')] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_url[created_at-dtype0] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_url[closed_at-datetime64[ns]] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_url[updated_at-dtype2] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_file_buffer_url.py::test_url[c_high] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_file_buffer_url.py::test_url[c_low] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/common/test_file_buffer_url.py::test_url[python] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[gzip-python-explicit] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[gzip-python-infer] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[gzip-c-explicit] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[gzip-c-infer] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[bz2-python-explicit] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[bz2-python-infer] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[bz2-c-explicit] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[bz2-c-infer] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[zip-python-explicit] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[zip-python-infer] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[zip-c-explicit] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[zip-c-infer] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[xz-python-explicit] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[xz-python-infer] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[xz-c-explicit] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[xz-c-infer] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[zstd-python-explicit] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[zstd-python-infer] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[zstd-c-explicit] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_compressed_urls[zstd-c-infer] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_network.py::test_url_encoding_csv 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/parser/test_read_fwf.py::test_url_urlopen 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py::TestReadHtml::test_banklist_url[bs4] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py::TestReadHtml::test_banklist_url[lxml] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py::TestReadHtml::test_spam_url[bs4] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py::TestReadHtml::test_spam_url[lxml] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py::TestReadHtml::test_multiple_matches[bs4] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py::TestReadHtml::test_multiple_matches[lxml] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py::TestReadHtml::test_python_docs_table[bs4] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_html.py::TestReadHtml::test_python_docs_table[lxml] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[None-csv_responder-read_csv] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[None-json_responder-read_json] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[None-html_responder-] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[None-pickle_respnder-read_pickle] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[None-stata_responder-read_stata] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[None-gz_csv_responder-read_csv] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[None-gz_json_responder-read_json] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options1-csv_responder-read_csv] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options1-json_responder-read_json] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options1-html_responder-] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options1-pickle_respnder-read_pickle] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options1-stata_responder-read_stata] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options1-gz_csv_responder-read_csv] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options1-gz_json_responder-read_json] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options2-csv_responder-read_csv] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options2-json_responder-read_json] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options2-html_responder-] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options2-pickle_respnder-read_pickle] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options2-stata_responder-read_stata] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options2-gz_csv_responder-read_csv] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_http_headers.py::test_request_headers[storage_options2-gz_json_responder-read_json] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py::test_url 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py::test_wrong_url[lxml] 637s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/xml/test_xml.py::test_wrong_url[etree] 637s = 67 failed, 12082 passed, 3016 skipped, 201 deselected, 155 xfailed, 3 warnings in 125.98s (0:02:05) = 638s + test 1 == 5 638s + TEST_SUCCESS=false 638s + echo 'rdjoqkol test state = false' 638s + for TEST_SUBSET in $modpath/tests/* 638s + echo /usr/lib/python3/dist-packages/pandas/tests/libs 638s + grep -q -e __pycache__ 638s + PANDAS_CI=1 638s + LC_ALL=C.UTF-8 638s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/libs 638s rdjoqkol test state = false 639s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 639s 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" 639s 639s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 639s ============================= test session starts ============================== 639s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 639s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 639s rootdir: /usr/lib/python3/dist-packages/pandas 639s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 639s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 639s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 639s collected 2279 items 639s 641s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_hashtable.py ..............s.....................................................................s.............s.......................................................s.............s.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s................................................................................................................................................................................................. 641s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_join.py ................. 641s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_lib.py .................................................................................. 641s ../../../usr/lib/python3/dist-packages/pandas/tests/libs/test_libalgos.py ........ 641s 641s =============================== warnings summary =============================== 641s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 641s /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-5ahi_f4w' 641s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 641s 641s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 641s /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-h137ni8i' 641s session.config.cache.set(STEPWISE_CACHE_DIR, []) 641s 641s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 641s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 641s ============================= slowest 30 durations ============================= 641s 0.01s teardown tests/libs/test_libalgos.py::TestInfinity::test_infinity_against_nan 641s 641s (29 durations < 0.005s hidden. Use -vv to show these durations.) 641s ================= 2273 passed, 6 skipped, 2 warnings in 2.28s ================== 641s rdjoqkol test state = false 641s + echo 'rdjoqkol test state = false' 641s + for TEST_SUBSET in $modpath/tests/* 641s + echo /usr/lib/python3/dist-packages/pandas/tests/plotting 641s + grep -q -e __pycache__ 641s + PANDAS_CI=1 641s + LC_ALL=C.UTF-8 641s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/plotting 642s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 642s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 642s 642s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 643s ============================= test session starts ============================== 643s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 643s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 643s rootdir: /usr/lib/python3/dist-packages/pandas 643s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 643s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 643s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 643s collected 1423 items / 212 deselected / 1211 selected 643s 656s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame.py ..................................................XX.........................s.s.s.s....................................................................................................x...................................................................................... 659s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_color.py ......................................................................................... 659s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_groupby.py ...... 660s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_legend.py x..................... 664s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_frame_subplots.py .........x....................XX................................................................... 665s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/frame/test_hist_box_by.py ............................. 665s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_backend.py .....s. 667s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_boxplot_method.py .................................................... 667s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_common.py ... 668s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_converter.py ............................................ 678s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_datetimelike.py ...............................................................................................................x..........................................x.......................x...............x..... 678s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_groupby.py ................. 681s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_hist_method.py ...........................x..x...................................................... 686s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_misc.py s....................sss...................sss...................sss.................................. 689s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_series.py ...............................XXXX.............................x........................................................x......................... 689s ../../../usr/lib/python3/dist-packages/pandas/tests/plotting/test_style.py ...................................... 689s 689s =============================== warnings summary =============================== 689s tests/plotting/frame/test_frame.py: 11 warnings 689s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2650: RuntimeWarning: divide by zero encountered in scalar divide 689s x_scale = 1.0 / inw 689s 689s tests/plotting/frame/test_frame.py: 11 warnings 689s /usr/lib/python3/dist-packages/matplotlib/transforms.py:2652: RuntimeWarning: invalid value encountered in scalar multiply 689s self._mtx = np.array([[x_scale, 0.0, -inl*x_scale], 689s 689s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 689s /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-k3z8pacp' 689s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 689s 689s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 689s /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-4l2abhqj' 689s session.config.cache.set(STEPWISE_CACHE_DIR, []) 689s 689s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 689s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 689s ============================= slowest 30 durations ============================= 689s 0.44s call tests/plotting/test_datetimelike.py::TestTSPlot::test_finder_daily 689s 0.43s call tests/plotting/test_converter.py::test_registry_mpl_resets 689s 0.40s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[bar] 689s 0.39s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[False] 689s 0.37s call tests/plotting/test_converter.py::TestRegistration::test_dont_register_by_default 689s 0.34s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis[True] 689s 0.34s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[True] 689s 0.32s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[barh] 689s 0.32s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_kde_df 689s 0.30s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_ts_share_axes 689s 0.30s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharex_and_ax 689s 0.29s call tests/plotting/test_misc.py::TestSeriesPlots::test_bootstrap_plot 689s 0.28s call tests/plotting/test_misc.py::TestDataFramePlots::test_scatter_matrix_axis_smaller[False] 689s 0.25s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_errorbar_timeseries[line] 689s 0.25s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[False-None-1-layout1] 689s 0.23s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_sharey_and_ax 689s 0.22s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_df_gridspec_patterns_vert_horiz 689s 0.22s call tests/plotting/test_hist_method.py::TestDataFrameGroupByPlots::test_histtype_argument[barstacked-True] 689s 0.22s call tests/plotting/test_boxplot_method.py::TestDataFrameGroupByPlots::test_boxplot_legacy3[True-UserWarning-3-layout0] 689s 0.21s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df 689s 0.20s call tests/plotting/test_misc.py::TestDataFramePlots::test_parallel_coordinates_with_sorted_labels 689s 0.19s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data1] 689s 0.19s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_hist_df_coord[data0] 689s 0.18s call tests/plotting/test_boxplot_method.py::TestDataFramePlots::test_stacked_boxplot_set_axis 689s 0.18s call tests/plotting/test_misc.py::test_savefig[index1-data0-hexbin] 689s 0.18s call tests/plotting/test_misc.py::test_savefig[index2-data0-hexbin] 689s 0.18s call tests/plotting/test_misc.py::test_savefig[index0-data0-hexbin] 689s 0.18s call tests/plotting/frame/test_frame_subplots.py::TestDataFramePlotsSubplots::test_subplots_constrained_layout 689s 0.16s call tests/plotting/test_datetimelike.py::TestTSPlot::test_tsplot_datetime[ME] 689s 0.16s call tests/plotting/frame/test_frame.py::TestDataFramePlots::test_plot_xy 689s = 1177 passed, 15 skipped, 212 deselected, 11 xfailed, 8 xpassed, 24 warnings in 46.81s = 689s rdjoqkol test state = false 689s + echo 'rdjoqkol test state = false' 689s + for TEST_SUBSET in $modpath/tests/* 689s + echo /usr/lib/python3/dist-packages/pandas/tests/reductions 689s + grep -q -e __pycache__ 689s + PANDAS_CI=1 689s + LC_ALL=C.UTF-8 689s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reductions 690s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 690s 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" 690s 690s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 690s ============================= test session starts ============================== 690s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 690s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 690s rootdir: /usr/lib/python3/dist-packages/pandas 690s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 690s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 690s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 690s collected 550 items 690s 691s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_reductions.py .....................................................................................................................................................................................................................................................................................................................................s....................................................................................................................................... 691s ../../../usr/lib/python3/dist-packages/pandas/tests/reductions/test_stat_reductions.py ......................................................................................... 691s 691s =============================== warnings summary =============================== 691s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 691s /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-saeg4qls' 691s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 691s 691s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 691s /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-dsbqsd2c' 691s session.config.cache.set(STEPWISE_CACHE_DIR, []) 691s 691s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 691s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 691s ============================= slowest 30 durations ============================= 691s 0.30s call tests/reductions/test_stat_reductions.py::TestSeriesStatReductions::test_skew 691s 0.03s call tests/reductions/test_reductions.py::TestReductions::test_same_tz_min_max_axis_1[max-a] 691s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-False] 691s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float64-True] 691s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-True] 691s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int64-False] 691s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-False] 691s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_int[int32-True] 691s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-True] 691s 0.01s call tests/reductions/test_reductions.py::TestSeriesReductions::test_sum_overflow_float[float32-False] 691s 691s (20 durations < 0.005s hidden. Use -vv to show these durations.) 691s ================== 549 passed, 1 skipped, 2 warnings in 1.42s ================== 691s rdjoqkol test state = false 691s + echo 'rdjoqkol test state = false' 691s + for TEST_SUBSET in $modpath/tests/* 691s + echo /usr/lib/python3/dist-packages/pandas/tests/resample 691s + grep -q -e __pycache__ 691s + PANDAS_CI=1 691s + LC_ALL=C.UTF-8 691s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/resample 692s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 692s 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" 692s 692s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 693s ============================= test session starts ============================== 693s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 693s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 693s rootdir: /usr/lib/python3/dist-packages/pandas 693s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 693s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 693s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 693s collected 4179 items 693s 695s ../../../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............................................................................................................................................................................................................................................................................................................................................................................................................................................................. 708s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_datetime_index.py ................................................................................ssss............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...x...x...x..........................................................................................................................................................................................................................................................................................................................................................................ss 711s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_period_index.py .................................................................................................................................................................................................................................................................................................................................................................................................................................x.................................................................................. 712s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resample_api.py ..................................................................................................................................................................................................... 712s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_resampler_grouper.py s................................................... 712s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_time_grouper.py .........................x...................... 712s ../../../usr/lib/python3/dist-packages/pandas/tests/resample/test_timedelta.py .......................s 712s 712s =============================== warnings summary =============================== 712s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 712s /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-2t7lwosl' 712s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 712s 712s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 712s /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-y53rsdrn' 712s session.config.cache.set(STEPWISE_CACHE_DIR, []) 712s 712s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 712s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 712s ============================= slowest 30 durations ============================= 712s 0.15s call tests/resample/test_datetime_index.py::test_resample_dtype_coercion[s] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-2] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-2] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-1] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-1] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-3] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-60-s-1-Min-3] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-1] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-1] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-2] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-1] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-30-s-0.5-Min-3] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-21600-s-0.25-D-2] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-1] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-43200-s-0.5-D-3] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-3600-s-1-h-2] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-21600-s-0.25-D-3] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-43200-s-0.5-D-2] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-21600-s-0.25-D-3] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-21600-s-0.25-D-1] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-60-s-1-Min-1] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-30-s-0.5-Min-3] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-2] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-1] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-30-s-0.5-Min-3] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-3600-s-1-h-2] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[us-86400-s-1-D-1] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-43200-s-0.5-D-2] 712s 0.09s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[s-60-s-1-Min-2] 712s 0.08s call tests/resample/test_datetime_index.py::test_resample_equivalent_offsets[ms-21600-s-0.25-D-2] 712s =========== 4117 passed, 8 skipped, 54 xfailed, 2 warnings in 20.33s =========== 713s rdjoqkol test state = false 713s + echo 'rdjoqkol test state = false' 713s + for TEST_SUBSET in $modpath/tests/* 713s + echo /usr/lib/python3/dist-packages/pandas/tests/reshape 713s + grep -q -e __pycache__ 713s + PANDAS_CI=1 713s + LC_ALL=C.UTF-8 713s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/reshape 713s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 713s 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" 713s 713s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 715s ============================= test session starts ============================== 715s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 715s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 715s rootdir: /usr/lib/python3/dist-packages/pandas 715s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 715s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 715s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 715s collected 2610 items / 1 deselected / 2609 selected 715s 715s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append.py .................................................................................. 715s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_append_common.py ...........................sssssssss....................................................... 715s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_categorical.py ............. 715s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_concat.py .............................................................................................. 715s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_dataframe.py ..................... 715s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_datetimes.py ..................................................................................................x......... 715s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_empty.py .....................s.....s.....s.....s.....s.......... 716s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_index.py ............................................................. 716s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_invalid.py ....... 716s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_series.py ............. 716s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/concat/test_sort.py .......... 716s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_join.py .......s..........................s....................................... 719s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................ssssssss..............................................................................................................................................................................................................................ss..........................................................................................................................................................................................................................................................................ssss........ 719s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_asof.py .s...................................................................................................s.....................s....s.s.s.s.............sss.. 719s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_cross.py ................. 719s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_index_as_string.py ................................................................................ 720s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_merge_ordered.py ..................... 720s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/merge/test_multi.py .....s.s.................................. 720s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_crosstab.py ..................................... 721s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_cut.py ..................................................................................................................................... 721s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_from_dummies.py ......................................... 721s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_get_dummies.py ...................................................................................................................................................ss 722s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_melt.py ..........................................................s 723s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot.py ...........................................................................xx................................................................................................. 723s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_pivot_multilevel.py .......... 724s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_qcut.py ................................................................................ 724s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_union_categoricals.py .......................................... 724s ../../../usr/lib/python3/dist-packages/pandas/tests/reshape/test_util.py ................. 724s 724s =============================== warnings summary =============================== 724s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 724s /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-87qg7uss' 724s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 724s 724s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 724s /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-4r595gly' 724s session.config.cache.set(STEPWISE_CACHE_DIR, []) 724s 724s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 724s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 724s ============================= slowest 30 durations ============================= 724s 0.05s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_multi_functions 724s 0.05s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize 724s 0.05s call tests/reshape/merge/test_join.py::TestJoin::test_full_outer_join 724s 0.04s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_non_unique_indexes 724s 0.04s call tests/reshape/test_pivot.py::TestPivotTable::test_margins 724s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_normalize 724s 0.03s call tests/reshape/test_crosstab.py::TestCrosstab::test_margin_dropna6 724s 0.03s call tests/reshape/concat/test_concat.py::TestConcatenate::test_concat_order 724s 0.03s call tests/reshape/merge/test_join.py::TestJoin::test_right_outer_join 724s 0.03s call tests/reshape/merge/test_multi.py::TestMergeMulti::test_compress_group_combinations 724s 0.03s call tests/reshape/test_qcut.py::test_qcut_binning_issues 724s 0.02s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper 724s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_normalize_arrays 724s 0.02s call tests/reshape/test_crosstab.py::test_categoricals[category-category] 724s 0.02s call tests/reshape/test_crosstab.py::test_categoricals[category-int64] 724s 0.02s call tests/reshape/test_crosstab.py::test_categoricals[int64-category] 724s 0.02s call tests/reshape/test_pivot.py::TestPivotTable::test_daily 724s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_margins_set_margin_name 724s 0.02s call tests/reshape/test_crosstab.py::test_categoricals[int64-int64] 724s 0.02s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_timegrouper_double 724s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[tuple] 724s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[list] 724s 0.02s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_ndarray[array] 724s 0.02s teardown tests/reshape/test_util.py::TestCartesianProduct::test_exceed_product_space 724s 0.02s call tests/reshape/test_pivot.py::TestPivotTable::test_pivot_table_margins_name_with_aggfunc_list 724s 0.02s call tests/reshape/merge/test_merge.py::TestMerge::test_validation 724s 0.02s call tests/reshape/merge/test_join.py::TestJoin::test_join_many_non_unique_index 724s 0.01s call tests/reshape/test_crosstab.py::TestCrosstab::test_crosstab_duplicate_names 724s 0.01s call tests/reshape/merge/test_merge.py::TestMerge::test_merge_indicator_result_integrity 724s 0.01s call tests/reshape/merge/test_join.py::TestJoin::test_left_outer_join 724s ==== 2561 passed, 45 skipped, 1 deselected, 3 xfailed, 2 warnings in 10.51s ==== 724s rdjoqkol test state = false 724s + echo 'rdjoqkol test state = false' 724s + for TEST_SUBSET in $modpath/tests/* 724s + echo /usr/lib/python3/dist-packages/pandas/tests/scalar 724s + grep -q -e __pycache__ 724s + PANDAS_CI=1 724s + LC_ALL=C.UTF-8 724s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/scalar 724s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 724s 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" 724s 724s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 727s ============================= test session starts ============================== 727s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 727s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 727s rootdir: /usr/lib/python3/dist-packages/pandas 727s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 727s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 727s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 727s collected 4353 items 727s 727s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_arithmetic.py ............................................ 727s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_constructors.py ......... 727s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_contains.py ................ 727s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_formats.py . 727s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_interval.py ............................................ 727s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/interval/test_overlaps.py ................................................................................................................................................................. 727s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_arithmetic.py .................................................................................... 727s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_asfreq.py ....................... 727s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/period/test_period.py ............................................................................................................................................................................................................................................................................................................... 727s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_na_scalar.py .....................................................................................ss.....ss.....ss................................................................................................................................................................................ 728s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/test_nat.py ........................................................................................................................s............s............................................................................................................................................................................................................................ 728s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_as_unit.py .... 728s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/methods/test_round.py ................... 728s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_arithmetic.py ................................................................................................................................ 728s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_constructors.py ................................................................................................................................................................................................................................................................................................................... 728s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_formats.py .............. 731s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timedelta/test_timedelta.py .................................................................x............ 731s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_as_unit.py .... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_normalize.py ................................................................................................................................................................. 731s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_replace.py ............................................................................................................................ 731s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_round.py ....................................................................................................................................................................................... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_timestamp_method.py . 731s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_julian_date.py ..... 731s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_to_pydatetime.py ....... 732s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_convert.py ............................................................................... 732s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/methods/test_tz_localize.py ................................................................................................................................................................................................. 732s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_arithmetic.py ............................................................................................................. 732s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_comparisons.py .............................. 732s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_constructors.py ..................................................................xxx.............................................................. 732s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_formats.py ........................................................................... 734s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timestamp.py .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x....................................................................................................................................................................................................................................................................................................................................... 734s ../../../usr/lib/python3/dist-packages/pandas/tests/scalar/timestamp/test_timezones.py .................... 734s 734s =============================== warnings summary =============================== 734s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 734s /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-2l80lz4t' 734s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 734s 734s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 734s /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-pqbykxzn' 734s session.config.cache.set(STEPWISE_CACHE_DIR, []) 734s 734s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 734s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 734s ============================= slowest 30 durations ============================= 734s 2.09s call tests/scalar/timedelta/test_timedelta.py::TestTimedeltas::test_hash_equality_invariance 734s 0.10s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[floor] 734s 0.10s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[round] 734s 0.09s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[round] 734s 0.09s call tests/scalar/timestamp/methods/test_round.py::TestTimestampRound::test_round_sanity[ceil] 734s 0.09s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[floor] 734s 0.08s call tests/scalar/timedelta/methods/test_round.py::TestTimedeltaRound::test_round_sanity[ceil] 734s 0.07s call tests/scalar/timestamp/test_timestamp.py::TestTimestampProperties::test_dow_parametric 734s 0.03s teardown tests/scalar/timestamp/test_timezones.py::TestTimestampTZOperations::test_timestamp_timetz_equivalent_with_datetime_tz[zoneinfo.ZoneInfo(key='UTC')] 734s 0.01s call tests/scalar/test_nat.py::test_nat_vector_field_access 734s 734s (20 durations < 0.005s hidden. Use -vv to show these durations.) 734s ============ 4340 passed, 8 skipped, 5 xfailed, 2 warnings in 9.96s ============ 735s rdjoqkol test state = false 735s + echo 'rdjoqkol test state = false' 735s + for TEST_SUBSET in $modpath/tests/* 735s + echo /usr/lib/python3/dist-packages/pandas/tests/series 735s + grep -q -e __pycache__ 735s + PANDAS_CI=1 735s + LC_ALL=C.UTF-8 735s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/series 735s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 735s 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" 735s 735s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 739s ============================= test session starts ============================== 739s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 739s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 739s rootdir: /usr/lib/python3/dist-packages/pandas 739s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 739s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 739s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 739s collected 13032 items / 2 skipped 739s 739s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_cat_accessor.py ................... 744s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_dt_accessor.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 744s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_sparse_accessor.py . 744s ../../../usr/lib/python3/dist-packages/pandas/tests/series/accessors/test_str_accessor.py .. 744s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_datetime.py ................. 744s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_delitem.py .... 744s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_get.py ............ 744s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_getitem.py .............................................................................................. 745s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_indexing.py .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 745s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_mask.py .... 745s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_set_value.py ... 748s ../../../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................................................................................................................................................................................................... 748s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_take.py .... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_where.py ......................................................................................................................................................................................................... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/indexing/test_xs.py ...... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_add_prefix_suffix.py ... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_align.py ............................................................................................................... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_argsort.py ......... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_asof.py ....... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_astype.py ........................................................s....s..........................................................................x........sssssssss.................s 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_autocorr.py . 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_between.py ....... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_case_when.py ........... 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_clip.py ....s.....s.....s.....s.....s.....s.....s.....s.....s.....s............ 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine.py . 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_combine_first.py .............................. 749s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_compare.py ............ 751s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_convert_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s......ss 751s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_copy.py .......... 751s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_count.py ... 751s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_cov_corr.py ................ 751s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_describe.py ...................................................... 751s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_diff.py ....... 751s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop.py ............................. 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_drop_duplicates.py ..................................................................ssssss.............................................................................................................................................................................................................................................................................................................ss 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dropna.py ........... 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_dtypes.py . 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_duplicated.py .................. 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_equals.py ..................................................... 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_explode.py ...............ssss 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_fillna.py ....................x.x.x................................................................................................................................. 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_get_numeric_data.py . 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_head_tail.py . 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_infer_objects.py ....... 752s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_info.py ........x..... 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_interpolate.py x.........................................................................................................................................................................................................x.x............. 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_monotonic.py .. 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_is_unique.py ........ 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isin.py ......................................... 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_isna.py .. 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_item.py . 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_map.py ......ss...................................xxx....................................................... 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_matmul.py . 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nlargest.py ................................................................. 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_nunique.py .. 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pct_change.py .............. 753s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_pop.py . 754s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_quantile.py ........................................ 754s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rank.py .......................................................................................................ssssssssssssssssssssssssssssss........................................................ssssssssssssssss.....ss.....ss.....ss.....ss.....ss.....................................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss.............................................ssssssssssssssssss. 754s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex.py ................................... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reindex_like.py .. 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename.py ................ 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_rename_axis.py ..... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_repeat.py ... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_replace.py ...........................s.......................................................................... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_reset_index.py ........s...... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_round.py ......................................................................................... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_searchsorted.py ........ 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_set_name.py .. 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_size.py ....... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_index.py .............................................. 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_sort_values.py .............. 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_csv.py ................................... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_dict.py ...... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_frame.py ... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_to_numpy.py ...s. 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tolist.py ..........sss 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_truncate.py .... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_tz_localize.py ................................................................ 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unique.py ....... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_unstack.py ....... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_update.py ....................s..... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_value_counts.py ................... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_values.py ... 755s ../../../usr/lib/python3/dist-packages/pandas/tests/series/methods/test_view.py .................................................. 756s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_api.py ................................s.......................................................................................................................................................... 761s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_arithmetic.py ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x...............................x............. 762s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_constructors.py ......................................................................................................................................................................................................................................x.........x............................................................................................s.................................xx.................................................sssssss.s...................... 762s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_cumulative.py ....................................... 762s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_formats.py .................................................. 762s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_iteration.py ....... 762s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_logical_ops.py ..........................xs 763s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_missing.py ...x.. 763s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_npfuncs.py ....s 763s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_reductions.py ..............s............... 763s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_subclass.py ......... 763s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_ufunc.py .....................................................................xxxx........................................................................................................................................ 763s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_unary.py .......................... 764s ../../../usr/lib/python3/dist-packages/pandas/tests/series/test_validate.py ............................ 764s 764s =============================== warnings summary =============================== 764s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 764s /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-xzpwo7cu' 764s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 764s 764s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 764s /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-5nft40b2' 764s session.config.cache.set(STEPWISE_CACHE_DIR, []) 764s 764s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 764s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 764s ============================= slowest 30 durations ============================= 764s 0.31s call tests/series/methods/test_rank.py::test_pct_max_many_rows 764s 0.30s call tests/series/methods/test_cov_corr.py::TestSeriesCorr::test_corr[float64] 764s 0.28s call tests/series/test_formats.py::TestSeriesRepr::test_latex_repr 764s 0.20s call tests/series/test_arithmetic.py::TestNamePreservation::test_series_ops_name_retention[numexpr-names2-mod-True-Series] 764s 0.13s call tests/series/methods/test_convert_dtypes.py::TestSeriesConvertDtypes::test_convert_dtypes[test_cases14-params5] 764s 0.09s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[br_FR.UTF-8] 764s 0.06s teardown tests/series/test_validate.py::test_validate_bool_args[5.0-drop_duplicates] 764s 0.05s call tests/series/methods/test_isin.py::TestSeriesIsIn::test_isin 764s 0.02s call tests/series/test_api.py::TestSeriesMisc::test_inspect_getmembers 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[mk_MK.UTF-8] 764s 0.01s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx1] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ber_MA.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[shn_MM.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[gbm_IN.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[gez_ER.UTF-8@abegede] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[da_DK.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[aa_ER.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[en_US.UTF-8_0] 764s 0.01s call tests/series/accessors/test_cat_accessor.py::TestCatAccessor::test_dt_accessor_api_for_categorical[idx0] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[mk_MK.ISO8859-5] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[am_ET.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[en_US.ISO8859-15] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ti_ER.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[el_GR.ISO8859-7] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[ar_IQ.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[byn_ER.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[en_HK.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[gez_ET.UTF-8] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[el_CY.ISO8859-7] 764s 0.01s call tests/series/accessors/test_dt_accessor.py::TestSeriesDatetimeValues::test_dt_accessor_datetime_name_accessors[de_DE.UTF-8] 764s ========= 12405 passed, 606 skipped, 23 xfailed, 2 warnings in 28.20s ========== 765s + echo 'rdjoqkol test state = false' 765s + for TEST_SUBSET in $modpath/tests/* 765s + echo /usr/lib/python3/dist-packages/pandas/tests/strings 765s rdjoqkol test state = false 765s + grep -q -e __pycache__ 765s + PANDAS_CI=1 765s + LC_ALL=C.UTF-8 765s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/strings 766s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 766s 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" 766s 766s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 766s ============================= test session starts ============================== 766s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 766s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 766s rootdir: /usr/lib/python3/dist-packages/pandas 766s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 766s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 766s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 766s collected 3604 items 766s 769s ../../../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 769s ../../../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 770s ../../../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...................................... 770s ../../../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 770s ../../../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 770s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_get_dummies.py ..ss...ss. 771s ../../../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 771s ../../../usr/lib/python3/dist-packages/pandas/tests/strings/test_string_array.py ...............................................................................sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....ssss....ssss.s 771s ../../../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....... 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-f5njnykh' 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-ac2x9kbl' 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.KKmu93/autopkgtest_tmp/test-data.xml --- 771s ============================= slowest 30 durations ============================= 771s 0.06s setup tests/strings/test_strings.py::test_count_mixed_object 771s 0.01s teardown tests/strings/test_strings.py::test_series_str_decode 771s 0.01s call tests/strings/test_strings.py::test_empty_str_methods[string[python]] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data7-names7] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data5-names5] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data6-names6] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data2-names2] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data3-names3] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data7-names7] 771s 0.01s call tests/strings/test_strings.py::test_empty_str_methods[object] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data1-names1] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data6-names6] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data0-names0] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[string[python]-data4-names4] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data5-names5] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data2-names2] 771s 0.01s call tests/strings/test_extract.py::test_extractall_same_as_extract_subject_index[string[python]] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data3-names3] 771s 0.01s call tests/strings/test_extract.py::test_extractall_no_matches[object-data0-names0] 771s 0.01s call tests/strings/test_extract.py::test_extract_expand_capture_groups[string[python]] 771s 771s (10 durations < 0.005s hidden. Use -vv to show these durations.) 771s ========== 2704 passed, 887 skipped, 13 xfailed, 2 warnings in 5.74s =========== 772s + echo 'rdjoqkol test state = false' 772s + for TEST_SUBSET in $modpath/tests/* 772s + echo /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 772s + grep -q -e __pycache__ 772s rdjoqkol test state = false 772s + PANDAS_CI=1 772s + LC_ALL=C.UTF-8 772s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py 772s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 772s 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" 772s 772s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 772s ============================= test session starts ============================== 772s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 772s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 772s rootdir: /usr/lib/python3/dist-packages/pandas 772s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 772s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 772s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 772s collected 8 items 772s 772s ../../../usr/lib/python3/dist-packages/pandas/tests/test_aggregation.py ........ 772s 772s =============================== warnings summary =============================== 772s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 772s /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-ovpynf5z' 772s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 772s 772s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 772s /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-o07d6pv8' 772s session.config.cache.set(STEPWISE_CACHE_DIR, []) 772s 772s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 772s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 772s ============================= slowest 30 durations ============================= 772s 772s (24 durations < 0.005s hidden. Use -vv to show these durations.) 772s ======================== 8 passed, 2 warnings in 0.09s ========================= 772s + echo 'rdjoqkol test state = false' 772s + for TEST_SUBSET in $modpath/tests/* 772s rdjoqkol test state = false 772s + echo /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 772s + grep -q -e __pycache__ 772s + PANDAS_CI=1 772s + LC_ALL=C.UTF-8 772s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_algos.py 773s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 773s 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" 773s 773s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 773s ============================= test session starts ============================== 773s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 773s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 773s rootdir: /usr/lib/python3/dist-packages/pandas 773s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 773s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 773s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 773s collected 471 items 773s 776s ../../../usr/lib/python3/dist-packages/pandas/tests/test_algos.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 776s 776s =============================== warnings summary =============================== 776s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 776s /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-0p82bzrm' 776s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 776s 776s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 776s /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-q295_qwe' 776s session.config.cache.set(STEPWISE_CACHE_DIR, []) 776s 776s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 776s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 776s ============================= slowest 30 durations ============================= 776s 1.87s call tests/test_algos.py::TestRank::test_pct_max_many_rows 776s 0.33s call tests/test_algos.py::TestRank::test_scipy_compat[arr0] 776s 0.01s call tests/test_algos.py::TestIsin::test_large 776s 0.01s call tests/test_algos.py::TestDuplicated::test_datetime_likes 776s 0.01s call tests/test_algos.py::TestUnique::test_object_refcount_bug 776s 776s (25 durations < 0.005s hidden. Use -vv to show these durations.) 776s ======================= 471 passed, 2 warnings in 3.01s ======================== 776s rdjoqkol test state = false 776s + echo 'rdjoqkol test state = false' 776s + for TEST_SUBSET in $modpath/tests/* 776s + echo /usr/lib/python3/dist-packages/pandas/tests/test_common.py 776s + grep -q -e __pycache__ 776s + PANDAS_CI=1 776s + LC_ALL=C.UTF-8 776s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_common.py 777s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 777s 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" 777s 777s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 777s ============================= test session starts ============================== 777s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 777s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 777s rootdir: /usr/lib/python3/dist-packages/pandas 777s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 777s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 777s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 777s collected 128 items 777s 778s ../../../usr/lib/python3/dist-packages/pandas/tests/test_common.py ...............x.x.............................................................................................................. 778s 778s =============================== warnings summary =============================== 778s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 778s /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-m44eix5j' 778s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 778s 778s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 778s /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-ww1tmnff' 778s session.config.cache.set(STEPWISE_CACHE_DIR, []) 778s 778s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 778s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 778s ============================= slowest 30 durations ============================= 778s 0.34s call tests/test_common.py::test_bz2_missing_import 778s 0.29s call tests/test_common.py::test_str_size 778s 778s (28 durations < 0.005s hidden. Use -vv to show these durations.) 778s ================== 126 passed, 2 xfailed, 2 warnings in 0.91s ================== 778s rdjoqkol test state = false 778s + echo 'rdjoqkol test state = false' 778s + for TEST_SUBSET in $modpath/tests/* 778s + echo /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 778s + grep -q -e __pycache__ 778s + PANDAS_CI=1 778s + LC_ALL=C.UTF-8 778s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py 778s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 778s 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" 778s 778s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 779s ============================= test session starts ============================== 779s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 779s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 779s rootdir: /usr/lib/python3/dist-packages/pandas 779s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 779s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 779s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 779s collected 26 items 779s 782s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sx.........s. 782s 782s =============================== warnings summary =============================== 782s tests/test_downstream.py::test_dask 782s /usr/lib/python3/dist-packages/dask/dataframe/__init__.py:49: FutureWarning: 782s Dask dataframe query planning is disabled because dask-expr is not installed. 782s 782s You can install it with `pip install dask[dataframe]` or `conda install dask`. 782s This will raise in a future version. 782s 782s warnings.warn(msg, FutureWarning) 782s 782s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 782s /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-z9vgb6ce' 782s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 782s 782s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 782s /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-syq71rdq' 782s session.config.cache.set(STEPWISE_CACHE_DIR, []) 782s 782s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 782s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 782s ============================= slowest 30 durations ============================= 782s 1.37s call tests/test_downstream.py::test_oo_optimizable 782s 1.33s call tests/test_downstream.py::test_oo_optimized_datetime_index_unpickle 782s 0.10s call tests/test_downstream.py::test_dask 782s 0.01s call tests/test_downstream.py::test_construct_dask_float_array_int_dtype_match_ndarray 782s 0.01s call tests/test_downstream.py::test_yaml_dump 782s 782s (25 durations < 0.005s hidden. Use -vv to show these durations.) 782s ============= 17 passed, 8 skipped, 1 xfailed, 3 warnings in 3.33s ============= 782s + echo 'rdjoqkol test state = false' 782s rdjoqkol test state = false 782s + for TEST_SUBSET in $modpath/tests/* 782s + echo /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 782s + grep -q -e __pycache__ 782s + PANDAS_CI=1 782s + LC_ALL=C.UTF-8 782s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_errors.py 782s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 782s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 782s 782s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 782s ============================= test session starts ============================== 782s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 782s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 782s rootdir: /usr/lib/python3/dist-packages/pandas 782s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 782s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 782s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 782s collected 36 items 782s 782s ../../../usr/lib/python3/dist-packages/pandas/tests/test_errors.py .................................... 782s 782s =============================== warnings summary =============================== 782s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 782s /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-wim47ett' 782s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 782s 782s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 782s /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-3uuqiclg' 782s session.config.cache.set(STEPWISE_CACHE_DIR, []) 782s 782s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 782s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 782s ============================= slowest 30 durations ============================= 782s 782s (30 durations < 0.005s hidden. Use -vv to show these durations.) 782s ======================== 36 passed, 2 warnings in 0.11s ======================== 783s rdjoqkol test state = false 783s + echo 'rdjoqkol test state = false' 783s + for TEST_SUBSET in $modpath/tests/* 783s + echo /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 783s + grep -q -e __pycache__ 783s + PANDAS_CI=1 783s + LC_ALL=C.UTF-8 783s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_expressions.py 783s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 783s 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" 783s 783s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 783s ============================= test session starts ============================== 783s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 783s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 783s rootdir: /usr/lib/python3/dist-packages/pandas 783s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 783s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 783s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 783s collected 243 items 783s 784s ../../../usr/lib/python3/dist-packages/pandas/tests/test_expressions.py ................................................................................................................................................................................................................................................... 784s 784s =============================== warnings summary =============================== 784s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 784s /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-6oboitcg' 784s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 784s 784s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 784s /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-v4al4ht9' 784s session.config.cache.set(STEPWISE_CACHE_DIR, []) 784s 784s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 784s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 784s ============================= slowest 30 durations ============================= 784s 0.01s call tests/test_expressions.py::TestExpressions::test_invalid 784s 0.01s call tests/test_expressions.py::TestExpressions::test_run_binary[ne-False-_mixed] 784s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_mixed] 784s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_frame] 784s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-False-_integer_integers] 784s 0.01s call tests/test_expressions.py::TestExpressions::test_run_arithmetic[floordiv-True-_mixed] 784s 784s (24 durations < 0.005s hidden. Use -vv to show these durations.) 784s ======================= 243 passed, 2 warnings in 0.92s ======================== 784s + echo 'rdjoqkol test state = false' 784s + for TEST_SUBSET in $modpath/tests/* 784s rdjoqkol test state = false 784s + echo /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 784s + grep -q -e __pycache__ 784s + PANDAS_CI=1 784s + LC_ALL=C.UTF-8 784s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_flags.py 785s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 785s 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" 785s 785s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 785s ============================= test session starts ============================== 785s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 785s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 785s rootdir: /usr/lib/python3/dist-packages/pandas 785s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 785s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 785s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 785s collected 5 items 785s 785s ../../../usr/lib/python3/dist-packages/pandas/tests/test_flags.py ..... 785s 785s =============================== warnings summary =============================== 785s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 785s /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-i2rlfdtb' 785s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 785s 785s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 785s /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-a3l0whwb' 785s session.config.cache.set(STEPWISE_CACHE_DIR, []) 785s 785s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 785s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 785s ============================= slowest 30 durations ============================= 785s 785s (15 durations < 0.005s hidden. Use -vv to show these durations.) 785s ======================== 5 passed, 2 warnings in 0.09s ========================= 785s + echo 'rdjoqkol test state = false' 785s + for TEST_SUBSET in $modpath/tests/* 785s rdjoqkol test state = false 785s + echo /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 785s + grep -q -e __pycache__ 785s + PANDAS_CI=1 785s + LC_ALL=C.UTF-8 785s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py 785s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 785s 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" 785s 785s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 786s ============================= test session starts ============================== 786s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 786s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 786s rootdir: /usr/lib/python3/dist-packages/pandas 786s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 786s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 786s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 786s collected 19 items 786s 786s ../../../usr/lib/python3/dist-packages/pandas/tests/test_multilevel.py ................... 786s 786s =============================== warnings summary =============================== 786s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 786s /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-nzuaiqyb' 786s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 786s 786s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 786s /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-sr3vi1vv' 786s session.config.cache.set(STEPWISE_CACHE_DIR, []) 786s 786s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 786s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 786s ============================= slowest 30 durations ============================= 786s 0.01s call tests/test_multilevel.py::TestMultiLevel::test_reindex_level 786s 786s (29 durations < 0.005s hidden. Use -vv to show these durations.) 786s ======================== 19 passed, 2 warnings in 0.17s ======================== 786s + echo 'rdjoqkol test state = false' 786s + for TEST_SUBSET in $modpath/tests/* 786s + echo /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 786s + grep -q -e __pycache__ 786s rdjoqkol test state = false 786s + PANDAS_CI=1 786s + LC_ALL=C.UTF-8 786s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_nanops.py 786s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 786s 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" 786s 786s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 786s ============================= test session starts ============================== 786s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 786s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 786s rootdir: /usr/lib/python3/dist-packages/pandas 786s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 786s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 786s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 786s collected 245 items 786s 787s ../../../usr/lib/python3/dist-packages/pandas/tests/test_nanops.py ..................................................................................................................................................................................................................................................... 787s 787s =============================== warnings summary =============================== 787s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 787s /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-m0eeof65' 787s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 787s 787s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 787s /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-alhscipa' 787s session.config.cache.set(STEPWISE_CACHE_DIR, []) 787s 787s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 787s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 787s ============================= slowest 30 durations ============================= 787s 0.31s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-0] 787s 0.03s call tests/test_nanops.py::test_has_infs_floats[f2-arr_inf-True] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[True] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[True] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nankurt[False] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-1] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[True-2] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanskew[False] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[True] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-0] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-2] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nansem[False-1] 787s 0.01s call tests/test_nanops.py::TestnanopsDataFrame::test_nanmedian[False] 787s 787s (17 durations < 0.005s hidden. Use -vv to show these durations.) 787s ======================= 245 passed, 2 warnings in 0.98s ======================== 787s + echo 'rdjoqkol test state = false' 787s + for TEST_SUBSET in $modpath/tests/* 787s + echo /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 787s rdjoqkol test state = false 787s + grep -q -e __pycache__ 787s + PANDAS_CI=1 787s + LC_ALL=C.UTF-8 787s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py 788s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 788s 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" 788s 788s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 788s ============================= test session starts ============================== 788s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 788s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 788s rootdir: /usr/lib/python3/dist-packages/pandas 788s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 788s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 788s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 788s collected 5 items 788s 788s ../../../usr/lib/python3/dist-packages/pandas/tests/test_optional_dependency.py ..... 788s 788s =============================== warnings summary =============================== 788s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 788s /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-37q2yrc7' 788s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 788s 788s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 788s /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-ahataxds' 788s session.config.cache.set(STEPWISE_CACHE_DIR, []) 788s 788s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 788s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 788s ============================= slowest 30 durations ============================= 788s 788s (15 durations < 0.005s hidden. Use -vv to show these durations.) 788s ======================== 5 passed, 2 warnings in 0.09s ========================= 788s rdjoqkol test state = false 788s + echo 'rdjoqkol test state = false' 788s + for TEST_SUBSET in $modpath/tests/* 788s + echo /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 788s + grep -q -e __pycache__ 788s + PANDAS_CI=1 788s + LC_ALL=C.UTF-8 788s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.py 789s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 789s 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" 789s 789s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 789s ============================= test session starts ============================== 789s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 789s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 789s rootdir: /usr/lib/python3/dist-packages/pandas 789s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 789s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 789s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 789s collected 7 items 789s 789s ../../../usr/lib/python3/dist-packages/pandas/tests/test_register_accessor.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-bwkl_y38' 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-hc09h1mp' 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.KKmu93/autopkgtest_tmp/test-data.xml --- 789s ============================= slowest 30 durations ============================= 789s 789s (21 durations < 0.005s hidden. Use -vv to show these durations.) 789s ======================== 7 passed, 2 warnings in 0.09s ========================= 789s rdjoqkol test state = false 789s + echo 'rdjoqkol test state = false' 789s + for TEST_SUBSET in $modpath/tests/* 789s + echo /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 789s + grep -q -e __pycache__ 789s + PANDAS_CI=1 789s + LC_ALL=C.UTF-8 789s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_sorting.py 790s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 790s 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" 790s 790s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 790s ============================= test session starts ============================== 790s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 790s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 790s rootdir: /usr/lib/python3/dist-packages/pandas 790s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 790s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 790s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 790s collected 54 items / 15 deselected / 39 selected 790s 791s ../../../usr/lib/python3/dist-packages/pandas/tests/test_sorting.py ....................................... 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-apzxxlun' 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-70akf9ox' 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.KKmu93/autopkgtest_tmp/test-data.xml --- 791s ============================= slowest 30 durations ============================= 791s 0.45s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_range 791s 0.21s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[mean] 791s 0.21s call tests/test_sorting.py::TestSorting::test_int64_overflow_groupby_large_df_shuffled[median] 791s 0.01s call tests/test_sorting.py::TestMerge::test_int64_overflow_outer_merge 791s 791s (26 durations < 0.005s hidden. Use -vv to show these durations.) 791s ================ 39 passed, 15 deselected, 2 warnings in 1.02s ================= 791s rdjoqkol test state = false 791s + echo 'rdjoqkol test state = false' 791s + for TEST_SUBSET in $modpath/tests/* 791s + echo /usr/lib/python3/dist-packages/pandas/tests/test_take.py 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.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/test_take.py 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.4, 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.KKmu93/build.UA1/src/pyproject.toml 791s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 791s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 791s collected 81 items 791s 791s ../../../usr/lib/python3/dist-packages/pandas/tests/test_take.py ................................................................................. 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-6j2a4s2b' 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-si4bsurx' 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.KKmu93/autopkgtest_tmp/test-data.xml --- 791s ============================= slowest 30 durations ============================= 791s 791s (30 durations < 0.005s hidden. Use -vv to show these durations.) 791s ======================== 81 passed, 2 warnings in 0.19s ======================== 792s + echo 'rdjoqkol test state = false' 792s + for TEST_SUBSET in $modpath/tests/* 792s + echo /usr/lib/python3/dist-packages/pandas/tests/tools 792s + grep -q -e __pycache__ 792s + PANDAS_CI=1 792s + LC_ALL=C.UTF-8 792s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tools 792s rdjoqkol test state = false 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)) 793s ============================= test session starts ============================== 793s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 793s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 793s rootdir: /usr/lib/python3/dist-packages/pandas 793s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 793s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 793s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 793s collected 1510 items 793s 795s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss....................................................................ss................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 795s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_numeric.py ...s.s....................................................................................................................................................................................................................................................xx.......................................................................................................................ssssss.s.s.................................sss...sss.s....ssss.s.s 795s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_time.py ........... 795s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_timedelta.py ........................................................................ssssssssssss 795s 795s =============================== warnings summary =============================== 795s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 795s /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-lv76270p' 795s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 795s 795s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 795s /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-h5kt1xyq' 795s session.config.cache.set(STEPWISE_CACHE_DIR, []) 795s 795s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 795s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 795s ============================= slowest 30 durations ============================= 795s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-True] 795s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-True] 795s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-None-None] 795s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-None] 795s 0.05s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[array-%Y%m%d %H:%M:%S-None] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-True] 795s 0.04s 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] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-True] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-None-True] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[deque-%Y%m%d %H:%M:%S-None] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-%Y%m%d %H:%M:%S-None] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-None] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[list-None-True] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-True] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-None-None] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-None] 795s 0.04s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[tuple-%Y%m%d %H:%M:%S-True] 795s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-True] 795s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-None-None] 795s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-True] 795s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-None] 795s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache[Index-%Y%m%d %H:%M:%S-None] 795s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[None-True] 795s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-True] 795s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_cache_series[%Y%m%d %H:%M:%S-None] 795s 0.02s call tests/tools/test_to_datetime.py::TestToDatetime::test_to_datetime_fixed_offset 795s 0.01s call tests/tools/test_to_datetime.py::TestToDatetimeMisc::test_to_datetime_timezone_name 795s 0.01s teardown tests/tools/test_to_timedelta.py::test_from_timedelta_arrow_dtype[ms] 795s 795s (2 durations < 0.005s hidden. Use -vv to show these durations.) 795s =========== 1451 passed, 55 skipped, 4 xfailed, 2 warnings in 3.33s ============ 796s + echo 'rdjoqkol test state = false' 796s + for TEST_SUBSET in $modpath/tests/* 796s + echo /usr/lib/python3/dist-packages/pandas/tests/tseries 796s rdjoqkol test state = false 796s + grep -q -e __pycache__ 796s + PANDAS_CI=1 796s + LC_ALL=C.UTF-8 796s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tseries 796s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 796s 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" 796s 796s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 797s ============================= test session starts ============================== 797s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 797s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 797s rootdir: /usr/lib/python3/dist-packages/pandas 797s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 797s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 797s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 797s collected 5480 items 797s 797s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_freq_code.py ................... 797s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_frequencies.py .......... 799s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/frequencies/test_inference.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 799s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_calendar.py ........ 799s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_federal.py ... 799s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_holiday.py ................................................. 799s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/holiday/test_observance.py ................................. 799s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_day.py ....................... 799s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_hour.py .............................................................................................. 799s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_month.py ..................... 799s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_quarter.py .............................................. 799s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_business_year.py ................... 800s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_common.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 800s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_day.py ....... 800s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_hour.py ............................ 800s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_custom_business_month.py .................................................... 800s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_dst.py .......................... 800s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_easter.py .......... 800s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_fiscal.py ............................................................................................................................................. 801s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_index.py ........................ 801s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_month.py ............................................................ 804s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x..................................................................................................................................................................................................................................................x................................................................................................................................................................................................................................................ 805s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_offsets_properties.py .. 805s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_quarter.py ........................................................................................ 806s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_ticks.py ............................................................................................................ 806s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_week.py .............................................. 806s ../../../usr/lib/python3/dist-packages/pandas/tests/tseries/offsets/test_year.py ................................. 806s 806s =============================== warnings summary =============================== 806s tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 806s /usr/lib/python3/dist-packages/dateutil/zoneinfo/__init__.py:26: UserWarning: I/O error(2): No such file or directory 806s warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) 806s 806s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 806s /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-tysrr158' 806s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 806s 806s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 806s /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-_xvtjsgb' 806s session.config.cache.set(STEPWISE_CACHE_DIR, []) 806s 806s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 806s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 806s ============================= slowest 30 durations ============================= 806s 0.35s call tests/tseries/offsets/test_offsets_properties.py::test_on_offset_implementations 806s 0.26s call tests/tseries/offsets/test_offsets_properties.py::test_shift_across_dst 806s 0.20s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Second] 806s 0.16s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Second] 806s 0.15s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Micro] 806s 0.15s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Milli] 806s 0.15s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Hour] 806s 0.15s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Nano] 806s 0.14s call tests/tseries/offsets/test_ticks.py::test_tick_equality[Minute] 806s 0.08s call tests/tseries/offsets/test_custom_business_day.py::TestCustomBusinessDay::test_calendar 806s 0.08s call tests/tseries/offsets/test_custom_business_hour.py::TestCustomBusinessHour::test_us_federal_holiday_with_datetime 806s 0.07s call tests/tseries/offsets/test_common.py::test_apply_out_of_range[tzlocal()-YearEnd] 806s 0.06s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Nano] 806s 0.06s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Hour] 806s 0.06s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Minute] 806s 0.06s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Micro] 806s 0.06s call tests/tseries/offsets/test_ticks.py::test_tick_add_sub[Milli] 806s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BYearEnd--2] 806s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterBegin--2] 806s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterBegin--2] 806s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BYearBegin--2] 806s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[YearBegin--2] 806s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[YearEnd--2] 806s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[BQuarterEnd--2] 806s 0.03s call tests/tseries/offsets/test_index.py::test_apply_index[QuarterEnd--2] 806s 0.03s teardown tests/tseries/offsets/test_year.py::test_add_out_of_pydatetime_range 806s 0.02s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthBegin--2] 806s 0.02s call tests/tseries/offsets/test_business_month.py::test_apply_index[BusinessMonthBegin--2] 806s 0.02s call tests/tseries/offsets/test_index.py::test_apply_index[MonthBegin--2] 806s 0.02s call tests/tseries/offsets/test_index.py::test_apply_index[BusinessMonthEnd--2] 806s ================= 5478 passed, 2 xfailed, 3 warnings in 10.25s ================= 807s + echo 'rdjoqkol test state = false' 807s + for TEST_SUBSET in $modpath/tests/* 807s + echo /usr/lib/python3/dist-packages/pandas/tests/tslibs 807s + grep -q -e __pycache__ 807s rdjoqkol test state = false 807s + PANDAS_CI=1 807s + LC_ALL=C.UTF-8 807s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/tslibs 808s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 808s 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" 808s 808s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 808s ============================= test session starts ============================== 808s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 808s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 808s rootdir: /usr/lib/python3/dist-packages/pandas 808s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 808s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 808s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 808s collected 1140 items 808s 808s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_api.py . 808s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_array_to_datetime.py ............................................ 808s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_ccalendar.py ................. 810s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_conversion.py ...................................................................... 810s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_fields.py .... 810s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_libfrequencies.py ............ 810s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_liboffsets.py .......................................................................... 810s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_np_datetime.py ........ 810s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_npy_units.py .. 810s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parse_iso8601.py ................................................... 815s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_parsing.py .............................................................................................................................................x...x................................. 815s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_period.py ....................................... 815s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_resolution.py ................... 815s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_strptime.py ....... 815s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timedeltas.py ......................... 815s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_timezones.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 815s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_to_offset.py ................................................................................................... 815s ../../../usr/lib/python3/dist-packages/pandas/tests/tslibs/test_tzconversion.py . 815s 815s =============================== warnings summary =============================== 815s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 815s /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-_6kyia38' 815s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 815s 815s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 815s /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-_9b8nreq' 815s session.config.cache.set(STEPWISE_CACHE_DIR, []) 815s 815s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 815s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 815s ============================= slowest 30 durations ============================= 815s 0.22s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-True-.] 815s 0.20s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %Y-False-.] 815s 0.19s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['dateutil/Asia/Singapore'] 815s 0.18s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[tzlocal()] 815s 0.15s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(seconds=3600))] 815s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['+01:15'] 815s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[datetime.timezone(datetime.timedelta(days=-1, seconds=82800), 'foo')] 815s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC-02:15'] 815s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['-02:15'] 815s 0.14s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['UTC+01:15'] 815s 0.13s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(-300)] 815s 0.13s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly[pytz.FixedOffset(300)] 815s 0.12s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False- ] 815s 0.10s call tests/tslibs/test_conversion.py::test_tz_convert_single_matches_tz_convert_hourly['Asia/Tokyo'] 815s 0.09s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%m %d %Y-False- ] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True- ] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True- ] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False-.] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-/] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True--] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False- ] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y%m%d-False-.] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-False--] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True-.] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-False-/] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y %m %d-True-/] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-True-.] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y%m%d-False--] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%Y %m %d-True--] 815s 0.07s call tests/tslibs/test_parsing.py::test_hypothesis_delimited_date[%y%m%d-True-/] 815s ================= 1138 passed, 2 xfailed, 2 warnings in 7.82s ================== 816s rdjoqkol test state = false 816s + echo 'rdjoqkol test state = false' 816s + for TEST_SUBSET in $modpath/tests/* 816s + echo /usr/lib/python3/dist-packages/pandas/tests/util 816s + grep -q -e __pycache__ 816s + PANDAS_CI=1 816s + LC_ALL=C.UTF-8 816s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/util 816s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 816s 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" 816s 816s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 817s ============================= test session starts ============================== 817s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 817s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 817s rootdir: /usr/lib/python3/dist-packages/pandas 817s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 817s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 817s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 817s collected 916 items 817s 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_almost_equal.py .................................................................................................................................................................... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_attr_equal.py .......................................... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_categorical_equal.py .......... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_extension_array_equal.py ..................... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_frame_equal.py ............................................................................................................... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_index_equal.py ................................................................ 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_interval_array_equal.py ....... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_numpy_array_equal.py ......................... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_produces_warning.py ............................................................................................................................ 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_assert_series_equal.py .............................................................................................. 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate.py ... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_kwarg.py .............. 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_deprecate_nonkeyword_arguments.py ................... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_doc.py .... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_hashing.py ..................................................................................................................................................... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_rewrite_warning.py .......... 817s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_shares_memory.py .s 818s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_show_versions.py .... 818s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_util.py ...sx.. 818s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args.py ...... 818s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_args_and_kwargs.py ...... 818s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_inclusive.py ........... 818s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_validate_kwargs.py .................. 818s 818s =============================== warnings summary =============================== 818s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 818s /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-r34yhgfn' 818s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 818s 818s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 818s /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-tsvw0jd1' 818s session.config.cache.set(STEPWISE_CACHE_DIR, []) 818s 818s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 818s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 818s ============================= slowest 30 durations ============================= 818s 0.50s call tests/util/test_show_versions.py::test_show_versions 818s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-7] 818s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-7] 818s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[0-6] 818s 0.01s call tests/util/test_show_versions.py::test_show_versions_console_json 818s 0.01s call tests/util/test_hashing.py::test_same_len_hash_collisions[1-6] 818s 0.01s call tests/util/test_show_versions.py::test_json_output_match 818s 818s (23 durations < 0.005s hidden. Use -vv to show these durations.) 818s ============ 913 passed, 2 skipped, 1 xfailed, 2 warnings in 1.93s ============= 818s + echo 'rdjoqkol test state = false' 818s + for TEST_SUBSET in $modpath/tests/* 818s + echo /usr/lib/python3/dist-packages/pandas/tests/window 818s + grep -q -e __pycache__ 818s rdjoqkol test state = false 818s + PANDAS_CI=1 818s + LC_ALL=C.UTF-8 818s + xvfb-run --auto-servernum '--server-args=-screen 0 1024x768x24' python3.13 -m pytest --tb=long -s -m 'not slow' -c /tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml --deb-data-root-dir=/tmp/autopkgtest.KKmu93/build.UA1/src/pandas/tests --rootdir=/usr/lib/python3/dist-packages/pandas /usr/lib/python3/dist-packages/pandas/tests/window 819s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 819s 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" 819s 819s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 820s ============================= test session starts ============================== 820s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 820s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 820s rootdir: /usr/lib/python3/dist-packages/pandas 820s configfile: ../../../../../tmp/autopkgtest.KKmu93/build.UA1/src/pyproject.toml 820s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 820s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 820s collected 10242 items / 536 deselected / 1 skipped / 9706 selected 820s 822s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 823s ../../../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................................................................................................................................................................................................................................................................................ 824s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 825s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 826s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 826s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 827s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 830s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 830s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 831s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 832s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 832s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 834s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 835s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 837s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 837s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 838s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 838s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 838s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 838s 838s =============================== warnings summary =============================== 838s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 838s /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-ue6mpin4' 838s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 838s 838s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 838s /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-y7a2mqli' 838s session.config.cache.set(STEPWISE_CACHE_DIR, []) 838s 838s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 838s -- generated xml file: /tmp/autopkgtest.KKmu93/autopkgtest_tmp/test-data.xml --- 838s ============================= slowest 30 durations ============================= 838s 0.34s call tests/window/test_rolling_functions.py::test_rolling_functions_window_non_shrinkage[14] 838s 0.13s teardown tests/window/test_numba.py::TestEngine::test_cache_apply[False-True-True-5-True] 838s 0.09s call tests/window/test_apply.py::test_time_rule_frame[False] 838s 0.05s teardown tests/window/test_win_type.py::test_rolling_center_axis_1 838s 0.05s call tests/window/test_apply.py::test_frame[False] 838s 0.03s call tests/window/test_expanding.py::test_expanding_corr_pairwise 838s 0.03s call tests/window/test_expanding.py::test_expanding_cov_pairwise 838s 0.02s call tests/window/test_apply.py::test_center_reindex_frame[False] 838s 0.02s call tests/window/test_apply.py::test_min_periods[False-None-0] 838s 0.02s call tests/window/test_apply.py::test_min_periods[False-1-0] 838s 0.02s call tests/window/test_apply.py::test_center_reindex_series[False] 838s 0.02s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[corr] 838s 0.02s call tests/window/test_pairwise.py::test_rolling_pairwise_cov_corr[cov] 838s 0.02s call tests/window/test_pairwise.py::TestPairwise::test_cov_mulittindex 838s 0.02s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[corr] 838s 0.02s call tests/window/test_pairwise.py::test_flex_binary_frame[corr] 838s 0.02s call tests/window/test_ewm.py::test_ewm_pairwise_cov_corr[cov] 838s 0.01s call tests/window/test_expanding.py::test_expanding_cov_pairwise_diff_length 838s 0.01s call tests/window/test_pairwise.py::test_flex_binary_frame[cov] 838s 0.01s call tests/window/test_expanding.py::test_expanding_corr_pairwise_diff_length 838s 0.01s call tests/window/test_apply.py::test_nans[False] 838s 0.01s call tests/window/test_apply.py::test_min_periods[False-2-0] 838s 0.01s call tests/window/test_api.py::test_agg[None] 838s 0.01s call tests/window/test_api.py::test_agg[10] 838s 0.01s call tests/window/test_api.py::test_agg[2] 838s 0.01s call tests/window/test_api.py::test_agg[5] 838s 0.01s call tests/window/test_api.py::test_agg[1] 838s 0.01s call tests/window/test_groupby.py::TestExpanding::test_expanding_corr_cov[cov] 838s 0.01s call tests/window/test_groupby.py::TestExpanding::test_expanding_corr_cov[corr] 838s 0.01s call tests/window/test_rolling.py::test_multi_index_names 838s == 9014 passed, 650 skipped, 536 deselected, 43 xfailed, 2 warnings in 19.31s == 839s rdjoqkol test state = false 839s + echo 'rdjoqkol test state = false' 839s + false 839s autopkgtest [20:50:08]: test unittests3: -----------------------] 840s autopkgtest [20:50:09]: test unittests3: - - - - - - - - - - results - - - - - - - - - - 840s unittests3 FAIL non-zero exit status 1 840s autopkgtest [20:50:09]: test ignoredtests: preparing testbed 840s Reading package lists... 841s Building dependency tree... 841s Reading state information... 841s Solving dependencies... 841s The following NEW packages will be installed: 841s libpq5 python3-psycopg2 python3-pymysql 841s 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. 841s Need to get 435 kB of archives. 841s After this operation, 1779 kB of additional disk space will be used. 841s Get:1 http://ftpmaster.internal/ubuntu questing/main amd64 libpq5 amd64 17.5-1build1 [253 kB] 841s Get:2 http://ftpmaster.internal/ubuntu questing/main amd64 python3-psycopg2 amd64 2.9.10-1build1 [142 kB] 841s Get:3 http://ftpmaster.internal/ubuntu questing/main amd64 python3-pymysql all 1.1.1-2ubuntu1 [39.5 kB] 841s Fetched 435 kB in 0s (19.8 MB/s) 841s Selecting previously unselected package libpq5:amd64. 841s (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 ... 104888 files and directories currently installed.) 841s Preparing to unpack .../libpq5_17.5-1build1_amd64.deb ... 841s Unpacking libpq5:amd64 (17.5-1build1) ... 841s Selecting previously unselected package python3-psycopg2. 841s Preparing to unpack .../python3-psycopg2_2.9.10-1build1_amd64.deb ... 841s Unpacking python3-psycopg2 (2.9.10-1build1) ... 841s Selecting previously unselected package python3-pymysql. 841s Preparing to unpack .../python3-pymysql_1.1.1-2ubuntu1_all.deb ... 841s Unpacking python3-pymysql (1.1.1-2ubuntu1) ... 841s Setting up libpq5:amd64 (17.5-1build1) ... 841s Setting up python3-psycopg2 (2.9.10-1build1) ... 841s Setting up python3-pymysql (1.1.1-2ubuntu1) ... 841s Processing triggers for libc-bin (2.41-6ubuntu2) ... 842s autopkgtest [20:50:11]: testbed environment configured for cross-architecture building 842s autopkgtest [20:50:11]: test ignoredtests: [----------------------- 842s === python3.13 === 843s 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 843s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 843s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 843s 843s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 845s ============================= test session starts ============================== 845s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 845s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 845s rootdir: /usr/lib/python3/dist-packages/pandas/tests 845s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 845s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 845s collected 10446 items / 536 deselected / 2 skipped / 9910 selected 845s 847s ../../../usr/lib/python3/dist-packages/pandas/tests/frame/test_ufunc.py ....xx.........xxxxxxxx.xx....s. 847s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py ..............................s 849s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 849s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 849s ../../../usr/lib/python3/dist-packages/pandas/tests/util/test_numba.py . 870s ../../../usr/lib/python3/dist-packages/pandas/tests/window/moments/test_moments_consistency_ewm.py ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 877s ../../../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................................................................................................................................................................................................................................................................................ 892s ../../../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................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 906s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_api.py ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 908s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_apply.py ...s....sssss..........s..s....................................................... 913s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_base_indexer.py .................................................................................................................................................................................................................................... 914s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_cython_aggregations.py ........................................................................ 958s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_dtypes.py .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 963s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_ewm.py .......................................................................................................................................................................................................................................ssssssssssss........ssssssssssssssss................ 969s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_expanding.py ..........x................................................................................................................................................................................................ss....s...................s..s......s............................................................................................. 972s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_groupby.py ................................................................................................................... 979s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss 986s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_pairwise.py ........................................................................................................................................................................................................................................................................................................................ 1003s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling.py ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ 1013s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_functions.py .................................................................................................................................................................................................................................................................................................................................................................................................................................. 1017s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_quantile.py .......................................................................................................................................................................................... 1023s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py .................................................................... 1025s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_timeseries_window.py ..................................................................................s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_win_type.py ............................................................................................................................................................................................................................................................................................... 1129s 1129s =============================== warnings summary =============================== 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_numba.py:11 1129s /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 1129s pytestmark = pytest.mark.single_cpu 1129s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/test_timegrouper.py:944 1129s /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 1129s @pytest.mark.single_cpu 1129s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/transform/test_numba.py:14 1129s /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 1129s pytestmark = pytest.mark.single_cpu 1129s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:22 1129s /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 1129s pytestmark = pytest.mark.single_cpu 1129s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/groupby/aggregate/test_numba.py:230 1129s /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 1129s @pytest.mark.single_cpu 1129s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:21 1129s /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 1129s pytestmark = pytest.mark.single_cpu 1129s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_numba.py:326 1129s /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 1129s @pytest.mark.slow 1129s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_online.py:11 1129s /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 1129s pytestmark = pytest.mark.single_cpu 1129s 1129s ../../../usr/lib/python3/dist-packages/pandas/tests/window/test_rolling_skew_kurt.py:155 1129s /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 1129s @pytest.mark.slow 1129s 1129s frame/test_ufunc.py: 32 warnings 1129s groupby/test_timegrouper.py: 31 warnings 1129s groupby/transform/test_numba.py: 53 warnings 1129s groupby/aggregate/test_numba.py: 35 warnings 1129s util/test_numba.py: 1 warning 1129s window/moments/test_moments_consistency_ewm.py: 1088 warnings 1129s window/moments/test_moments_consistency_expanding.py: 380 warnings 1129s window/moments/test_moments_consistency_rolling.py: 760 warnings 1129s window/test_api.py: 937 warnings 1129s window/test_apply.py: 82 warnings 1129s window/test_base_indexer.py: 228 warnings 1129s window/test_cython_aggregations.py: 72 warnings 1129s window/test_dtypes.py: 2580 warnings 1129s window/test_ewm.py: 283 warnings 1129s window/test_expanding.py: 333 warnings 1129s window/test_groupby.py: 115 warnings 1129s window/test_numba.py: 51 warnings 1129s window/test_pairwise.py: 312 warnings 1129s window/test_rolling.py: 888 warnings 1129s window/test_rolling_functions.py: 418 warnings 1129s window/test_rolling_quantile.py: 186 warnings 1129s window/test_rolling_skew_kurt.py: 68 warnings 1129s window/test_timeseries_window.py: 83 warnings 1129s window/test_win_type.py: 287 warnings 1129s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=7330) is multi-threaded, use of fork() may lead to deadlocks in the child. 1129s pid = os.fork() 1129s 1129s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1129s /usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/nodeids: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-sjji_p5t' 1129s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1129s 1129s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1129s /usr/lib/python3/dist-packages/_pytest/stepwise.py:51: PytestCacheWarning: could not create cache path /usr/lib/python3/dist-packages/pandas/tests/.pytest_cache/v/cache/stepwise: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/pandas/tests/pytest-cache-files-hwzb9ls4' 1129s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1129s 1129s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1129s = 9064 passed, 793 skipped, 536 deselected, 55 xfailed, 9314 warnings in 285.22s (0:04:45) = 1129s various xfailed tests - see xfail_tests_nonintel_io.patch, ignore_test_1094417_1088988.patch 1130s /usr/lib/python3/dist-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. 1130s The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" 1130s 1130s warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) 1131s ============================= test session starts ============================== 1131s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 1131s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1131s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1131s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 1131s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1131s collected 366 items 1131s 1140s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py ...................................................FFFFFFFFF................................................................................................................................... 1142s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py ....F................ 1146s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py ............................................F..................... 1150s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py ....s..sssss.sF.........s. 1153s ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py ..F.............FF..F.sFFFFFF................................. 1153s 1153s =================================== FAILURES =================================== 1153s ___________________________ test_complibs[blosc2-1] ____________________________ 1153s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-52/test_complibs_blosc2_1_0') 1153s lvl = 1, lib = 'blosc2' 1153s request = > 1153s 1153s @pytest.mark.parametrize("lvl", range(10)) 1153s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1153s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1153s @pytest.mark.skipif( 1153s not PY311 and is_ci_environment() and is_platform_linux(), 1153s reason="Segfaulting in a CI environment" 1153s # with xfail, would sometimes raise UnicodeDecodeError 1153s # invalid state byte 1153s ) 1153s def test_complibs(tmp_path, lvl, lib, request): 1153s # GH14478 1153s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1153s request.applymarker( 1153s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1153s ) 1153s df = DataFrame( 1153s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1153s ) 1153s 1153s # Remove lzo if its not available on this platform 1153s if not tables.which_lib_version("lzo"): 1153s pytest.skip("lzo not available") 1153s # Remove bzip2 if its not available on this platform 1153s if not tables.which_lib_version("bzip2"): 1153s pytest.skip("bzip2 not available") 1153s 1153s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1153s gname = f"{lvl}_{lib}" 1153s 1153s # Write and read file to see if data is consistent 1153s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1153s result = read_hdf(tmpfile, gname) 1153s tm.assert_frame_equal(result, df) 1153s 1153s # Open file and check metadata for correct amount of compression 1153s with tables.open_file(tmpfile, mode="r") as h5table: 1153s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1153s assert node.filters.complevel == lvl 1153s if lvl == 0: 1153s assert node.filters.complib is None 1153s else: 1153s > assert node.filters.complib == lib 1153s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1153s E 1153s E - blosc2 1153s E + blosc2:blosclz 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1153s ___________________________ test_complibs[blosc2-2] ____________________________ 1153s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-53/test_complibs_blosc2_2_0') 1153s lvl = 2, lib = 'blosc2' 1153s request = > 1153s 1153s @pytest.mark.parametrize("lvl", range(10)) 1153s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1153s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1153s @pytest.mark.skipif( 1153s not PY311 and is_ci_environment() and is_platform_linux(), 1153s reason="Segfaulting in a CI environment" 1153s # with xfail, would sometimes raise UnicodeDecodeError 1153s # invalid state byte 1153s ) 1153s def test_complibs(tmp_path, lvl, lib, request): 1153s # GH14478 1153s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1153s request.applymarker( 1153s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1153s ) 1153s df = DataFrame( 1153s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1153s ) 1153s 1153s # Remove lzo if its not available on this platform 1153s if not tables.which_lib_version("lzo"): 1153s pytest.skip("lzo not available") 1153s # Remove bzip2 if its not available on this platform 1153s if not tables.which_lib_version("bzip2"): 1153s pytest.skip("bzip2 not available") 1153s 1153s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1153s gname = f"{lvl}_{lib}" 1153s 1153s # Write and read file to see if data is consistent 1153s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1153s result = read_hdf(tmpfile, gname) 1153s tm.assert_frame_equal(result, df) 1153s 1153s # Open file and check metadata for correct amount of compression 1153s with tables.open_file(tmpfile, mode="r") as h5table: 1153s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1153s assert node.filters.complevel == lvl 1153s if lvl == 0: 1153s assert node.filters.complib is None 1153s else: 1153s > assert node.filters.complib == lib 1153s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1153s E 1153s E - blosc2 1153s E + blosc2:blosclz 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1153s ___________________________ test_complibs[blosc2-3] ____________________________ 1153s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-54/test_complibs_blosc2_3_0') 1153s lvl = 3, lib = 'blosc2' 1153s request = > 1153s 1153s @pytest.mark.parametrize("lvl", range(10)) 1153s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1153s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1153s @pytest.mark.skipif( 1153s not PY311 and is_ci_environment() and is_platform_linux(), 1153s reason="Segfaulting in a CI environment" 1153s # with xfail, would sometimes raise UnicodeDecodeError 1153s # invalid state byte 1153s ) 1153s def test_complibs(tmp_path, lvl, lib, request): 1153s # GH14478 1153s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1153s request.applymarker( 1153s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1153s ) 1153s df = DataFrame( 1153s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1153s ) 1153s 1153s # Remove lzo if its not available on this platform 1153s if not tables.which_lib_version("lzo"): 1153s pytest.skip("lzo not available") 1153s # Remove bzip2 if its not available on this platform 1153s if not tables.which_lib_version("bzip2"): 1153s pytest.skip("bzip2 not available") 1153s 1153s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1153s gname = f"{lvl}_{lib}" 1153s 1153s # Write and read file to see if data is consistent 1153s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1153s result = read_hdf(tmpfile, gname) 1153s tm.assert_frame_equal(result, df) 1153s 1153s # Open file and check metadata for correct amount of compression 1153s with tables.open_file(tmpfile, mode="r") as h5table: 1153s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1153s assert node.filters.complevel == lvl 1153s if lvl == 0: 1153s assert node.filters.complib is None 1153s else: 1153s > assert node.filters.complib == lib 1153s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1153s E 1153s E - blosc2 1153s E + blosc2:blosclz 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1153s ___________________________ test_complibs[blosc2-4] ____________________________ 1153s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-55/test_complibs_blosc2_4_0') 1153s lvl = 4, lib = 'blosc2' 1153s request = > 1153s 1153s @pytest.mark.parametrize("lvl", range(10)) 1153s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1153s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1153s @pytest.mark.skipif( 1153s not PY311 and is_ci_environment() and is_platform_linux(), 1153s reason="Segfaulting in a CI environment" 1153s # with xfail, would sometimes raise UnicodeDecodeError 1153s # invalid state byte 1153s ) 1153s def test_complibs(tmp_path, lvl, lib, request): 1153s # GH14478 1153s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1153s request.applymarker( 1153s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1153s ) 1153s df = DataFrame( 1153s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1153s ) 1153s 1153s # Remove lzo if its not available on this platform 1153s if not tables.which_lib_version("lzo"): 1153s pytest.skip("lzo not available") 1153s # Remove bzip2 if its not available on this platform 1153s if not tables.which_lib_version("bzip2"): 1153s pytest.skip("bzip2 not available") 1153s 1153s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1153s gname = f"{lvl}_{lib}" 1153s 1153s # Write and read file to see if data is consistent 1153s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1153s result = read_hdf(tmpfile, gname) 1153s tm.assert_frame_equal(result, df) 1153s 1153s # Open file and check metadata for correct amount of compression 1153s with tables.open_file(tmpfile, mode="r") as h5table: 1153s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1153s assert node.filters.complevel == lvl 1153s if lvl == 0: 1153s assert node.filters.complib is None 1153s else: 1153s > assert node.filters.complib == lib 1153s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1153s E 1153s E - blosc2 1153s E + blosc2:blosclz 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1153s ___________________________ test_complibs[blosc2-5] ____________________________ 1153s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-56/test_complibs_blosc2_5_0') 1153s lvl = 5, lib = 'blosc2' 1153s request = > 1153s 1153s @pytest.mark.parametrize("lvl", range(10)) 1153s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1153s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1153s @pytest.mark.skipif( 1153s not PY311 and is_ci_environment() and is_platform_linux(), 1153s reason="Segfaulting in a CI environment" 1153s # with xfail, would sometimes raise UnicodeDecodeError 1153s # invalid state byte 1153s ) 1153s def test_complibs(tmp_path, lvl, lib, request): 1153s # GH14478 1153s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1153s request.applymarker( 1153s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1153s ) 1153s df = DataFrame( 1153s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1153s ) 1153s 1153s # Remove lzo if its not available on this platform 1153s if not tables.which_lib_version("lzo"): 1153s pytest.skip("lzo not available") 1153s # Remove bzip2 if its not available on this platform 1153s if not tables.which_lib_version("bzip2"): 1153s pytest.skip("bzip2 not available") 1153s 1153s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1153s gname = f"{lvl}_{lib}" 1153s 1153s # Write and read file to see if data is consistent 1153s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1153s result = read_hdf(tmpfile, gname) 1153s tm.assert_frame_equal(result, df) 1153s 1153s # Open file and check metadata for correct amount of compression 1153s with tables.open_file(tmpfile, mode="r") as h5table: 1153s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1153s assert node.filters.complevel == lvl 1153s if lvl == 0: 1153s assert node.filters.complib is None 1153s else: 1153s > assert node.filters.complib == lib 1153s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1153s E 1153s E - blosc2 1153s E + blosc2:blosclz 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1153s ___________________________ test_complibs[blosc2-6] ____________________________ 1153s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-57/test_complibs_blosc2_6_0') 1153s lvl = 6, lib = 'blosc2' 1153s request = > 1153s 1153s @pytest.mark.parametrize("lvl", range(10)) 1153s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1153s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1153s @pytest.mark.skipif( 1153s not PY311 and is_ci_environment() and is_platform_linux(), 1153s reason="Segfaulting in a CI environment" 1153s # with xfail, would sometimes raise UnicodeDecodeError 1153s # invalid state byte 1153s ) 1153s def test_complibs(tmp_path, lvl, lib, request): 1153s # GH14478 1153s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1153s request.applymarker( 1153s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1153s ) 1153s df = DataFrame( 1153s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1153s ) 1153s 1153s # Remove lzo if its not available on this platform 1153s if not tables.which_lib_version("lzo"): 1153s pytest.skip("lzo not available") 1153s # Remove bzip2 if its not available on this platform 1153s if not tables.which_lib_version("bzip2"): 1153s pytest.skip("bzip2 not available") 1153s 1153s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1153s gname = f"{lvl}_{lib}" 1153s 1153s # Write and read file to see if data is consistent 1153s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1153s result = read_hdf(tmpfile, gname) 1153s tm.assert_frame_equal(result, df) 1153s 1153s # Open file and check metadata for correct amount of compression 1153s with tables.open_file(tmpfile, mode="r") as h5table: 1153s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1153s assert node.filters.complevel == lvl 1153s if lvl == 0: 1153s assert node.filters.complib is None 1153s else: 1153s > assert node.filters.complib == lib 1153s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1153s E 1153s E - blosc2 1153s E + blosc2:blosclz 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1153s ___________________________ test_complibs[blosc2-7] ____________________________ 1153s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-58/test_complibs_blosc2_7_0') 1153s lvl = 7, lib = 'blosc2' 1153s request = > 1153s 1153s @pytest.mark.parametrize("lvl", range(10)) 1153s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1153s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1153s @pytest.mark.skipif( 1153s not PY311 and is_ci_environment() and is_platform_linux(), 1153s reason="Segfaulting in a CI environment" 1153s # with xfail, would sometimes raise UnicodeDecodeError 1153s # invalid state byte 1153s ) 1153s def test_complibs(tmp_path, lvl, lib, request): 1153s # GH14478 1153s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1153s request.applymarker( 1153s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1153s ) 1153s df = DataFrame( 1153s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1153s ) 1153s 1153s # Remove lzo if its not available on this platform 1153s if not tables.which_lib_version("lzo"): 1153s pytest.skip("lzo not available") 1153s # Remove bzip2 if its not available on this platform 1153s if not tables.which_lib_version("bzip2"): 1153s pytest.skip("bzip2 not available") 1153s 1153s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1153s gname = f"{lvl}_{lib}" 1153s 1153s # Write and read file to see if data is consistent 1153s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1153s result = read_hdf(tmpfile, gname) 1153s tm.assert_frame_equal(result, df) 1153s 1153s # Open file and check metadata for correct amount of compression 1153s with tables.open_file(tmpfile, mode="r") as h5table: 1153s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1153s assert node.filters.complevel == lvl 1153s if lvl == 0: 1153s assert node.filters.complib is None 1153s else: 1153s > assert node.filters.complib == lib 1153s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1153s E 1153s E - blosc2 1153s E + blosc2:blosclz 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1153s ___________________________ test_complibs[blosc2-8] ____________________________ 1153s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-59/test_complibs_blosc2_8_0') 1153s lvl = 8, lib = 'blosc2' 1153s request = > 1153s 1153s @pytest.mark.parametrize("lvl", range(10)) 1153s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1153s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1153s @pytest.mark.skipif( 1153s not PY311 and is_ci_environment() and is_platform_linux(), 1153s reason="Segfaulting in a CI environment" 1153s # with xfail, would sometimes raise UnicodeDecodeError 1153s # invalid state byte 1153s ) 1153s def test_complibs(tmp_path, lvl, lib, request): 1153s # GH14478 1153s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1153s request.applymarker( 1153s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1153s ) 1153s df = DataFrame( 1153s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1153s ) 1153s 1153s # Remove lzo if its not available on this platform 1153s if not tables.which_lib_version("lzo"): 1153s pytest.skip("lzo not available") 1153s # Remove bzip2 if its not available on this platform 1153s if not tables.which_lib_version("bzip2"): 1153s pytest.skip("bzip2 not available") 1153s 1153s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1153s gname = f"{lvl}_{lib}" 1153s 1153s # Write and read file to see if data is consistent 1153s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1153s result = read_hdf(tmpfile, gname) 1153s tm.assert_frame_equal(result, df) 1153s 1153s # Open file and check metadata for correct amount of compression 1153s with tables.open_file(tmpfile, mode="r") as h5table: 1153s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1153s assert node.filters.complevel == lvl 1153s if lvl == 0: 1153s assert node.filters.complib is None 1153s else: 1153s > assert node.filters.complib == lib 1153s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1153s E 1153s E - blosc2 1153s E + blosc2:blosclz 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1153s ___________________________ test_complibs[blosc2-9] ____________________________ 1153s tmp_path = PosixPath('/tmp/pytest-of-ubuntu/pytest-60/test_complibs_blosc2_9_0') 1153s lvl = 9, lib = 'blosc2' 1153s request = > 1153s 1153s @pytest.mark.parametrize("lvl", range(10)) 1153s @pytest.mark.parametrize("lib", tables.filters.all_complibs) 1153s @pytest.mark.filterwarnings("ignore:object name is not a valid") 1153s @pytest.mark.skipif( 1153s not PY311 and is_ci_environment() and is_platform_linux(), 1153s reason="Segfaulting in a CI environment" 1153s # with xfail, would sometimes raise UnicodeDecodeError 1153s # invalid state byte 1153s ) 1153s def test_complibs(tmp_path, lvl, lib, request): 1153s # GH14478 1153s if PY311 and is_platform_linux() and lib == "blosc2" and lvl != 0: 1153s request.applymarker( 1153s pytest.mark.xfail(reason=f"Fails for {lib} on Linux and PY > 3.11", strict=False) 1153s ) 1153s df = DataFrame( 1153s np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_) 1153s ) 1153s 1153s # Remove lzo if its not available on this platform 1153s if not tables.which_lib_version("lzo"): 1153s pytest.skip("lzo not available") 1153s # Remove bzip2 if its not available on this platform 1153s if not tables.which_lib_version("bzip2"): 1153s pytest.skip("bzip2 not available") 1153s 1153s tmpfile = tmp_path / f"{lvl}_{lib}.h5" 1153s gname = f"{lvl}_{lib}" 1153s 1153s # Write and read file to see if data is consistent 1153s df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl) 1153s result = read_hdf(tmpfile, gname) 1153s tm.assert_frame_equal(result, df) 1153s 1153s # Open file and check metadata for correct amount of compression 1153s with tables.open_file(tmpfile, mode="r") as h5table: 1153s for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"): 1153s assert node.filters.complevel == lvl 1153s if lvl == 0: 1153s assert node.filters.complib is None 1153s else: 1153s > assert node.filters.complib == lib 1153s E AssertionError: assert 'blosc2:blosclz' == 'blosc2' 1153s E 1153s E - blosc2 1153s E + blosc2:blosclz 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:301: AssertionError 1153s ______________________ test_append_frame_column_oriented _______________________ 1153s self = 1153s node = , kwargs = {'side': 'right'} 1153s value = 1153s slobj = slice(0, 4, None) 1153s 1153s def visit_Subscript(self, node, **kwargs) -> ops.Term: 1153s # only allow simple subscripts 1153s 1153s value = self.visit(node.value) 1153s slobj = self.visit(node.slice) 1153s try: 1153s value = value.value 1153s except AttributeError: 1153s pass 1153s 1153s if isinstance(slobj, Term): 1153s # In py39 np.ndarray lookups with Term containing int raise 1153s slobj = slobj.value 1153s 1153s try: 1153s > return self.const_type(value[slobj], self.env) 1153s E TypeError: 'builtin_function_or_method' object is not subscriptable 1153s 1153s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:468: TypeError 1153s 1153s The above exception was the direct cause of the following exception: 1153s 1153s setup_path = 'tmp.__02bc0875-bd6e-497c-bec2-924d11d751a8__.h5' 1153s 1153s @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) 1153s def test_append_frame_column_oriented(setup_path): 1153s with ensure_clean_store(setup_path) as store: 1153s # column oriented 1153s df = DataFrame( 1153s np.random.default_rng(2).standard_normal((10, 4)), 1153s columns=Index(list("ABCD"), dtype=object), 1153s index=date_range("2000-01-01", periods=10, freq="B"), 1153s ) 1153s df.index = df.index._with_freq(None) # freq doesn't round-trip 1153s 1153s _maybe_remove(store, "df1") 1153s store.append("df1", df.iloc[:, :2], axes=["columns"]) 1153s store.append("df1", df.iloc[:, 2:]) 1153s tm.assert_frame_equal(store["df1"], df) 1153s 1153s result = store.select("df1", "columns=A") 1153s expected = df.reindex(columns=["A"]) 1153s tm.assert_frame_equal(expected, result) 1153s 1153s # selection on the non-indexable 1153s > result = store.select("df1", ("columns=A", "index=df.index[0:4]")) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:311: 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 1153s return it.get_result() 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 1153s results = self.func(self.start, self.stop, where) 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 1153s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 1153s result = self._read_axes(where=where, start=start, stop=stop) 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 1153s selection = Selection(self, where=where, start=start, stop=stop) 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 1153s self.terms = self.generate(where) 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 1153s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 1153s self.terms = self.parse() 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 1153s return self._visitor.visit(self.expr) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 1153s return self.visit(expr, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 1153s return self.visit(node.value, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:742: in visit_BoolOp 1153s return reduce(visitor, operands) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:736: in visitor 1153s rhs = self._try_visit_binop(y) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:731: in _try_visit_binop 1153s return self.visit(bop) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 1153s return self.visit(binop) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 1153s op, op_class, left, right = self._maybe_transform_eq_ne(node) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 1153s right = self.visit(node.right, side="right") 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s 1153s self = 1153s node = , kwargs = {'side': 'right'} 1153s value = 1153s slobj = slice(0, 4, None) 1153s 1153s def visit_Subscript(self, node, **kwargs) -> ops.Term: 1153s # only allow simple subscripts 1153s 1153s value = self.visit(node.value) 1153s slobj = self.visit(node.slice) 1153s try: 1153s value = value.value 1153s except AttributeError: 1153s pass 1153s 1153s if isinstance(slobj, Term): 1153s # In py39 np.ndarray lookups with Term containing int raise 1153s slobj = slobj.value 1153s 1153s try: 1153s return self.const_type(value[slobj], self.env) 1153s except TypeError as err: 1153s > raise ValueError( 1153s f"cannot subscript {repr(value)} with {repr(slobj)}" 1153s ) from err 1153s E ValueError: cannot subscript with slice(0, 4, None) 1153s 1153s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:470: ValueError 1153s __________________________ test_select_filter_corner ___________________________ 1153s setup_path = 'tmp.__0a1f799e-3412-4921-97ba-756690e3a224__.h5' 1153s 1153s @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) 1153s def test_select_filter_corner(setup_path): 1153s df = DataFrame(np.random.default_rng(2).standard_normal((50, 100))) 1153s df.index = [f"{c:3d}" for c in df.index] 1153s df.columns = [f"{c:3d}" for c in df.columns] 1153s 1153s with ensure_clean_store(setup_path) as store: 1153s store.put("frame", df, format="table") 1153s 1153s crit = "columns=df.columns[:75]" 1153s > result = store.select("frame", [crit]) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:899: 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:915: in select 1153s return it.get_result() 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:2038: in get_result 1153s results = self.func(self.start, self.stop, where) 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:899: in func 1153s return s.read(start=_start, stop=_stop, where=_where, columns=columns) 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:4640: in read 1153s result = self._read_axes(where=where, start=start, stop=stop) 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:3826: in _read_axes 1153s selection = Selection(self, where=where, start=start, stop=stop) 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5367: in __init__ 1153s self.terms = self.generate(where) 1153s /usr/lib/python3/dist-packages/pandas/io/pytables.py:5380: in generate 1153s return PyTablesExpr(where, queryables=q, encoding=self.table.encoding) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:610: in __init__ 1153s self.terms = self.parse() 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:824: in parse 1153s return self._visitor.visit(self.expr) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:417: in visit_Module 1153s return self.visit(expr, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:420: in visit_Expr 1153s return self.visit(node.value, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:715: in visit_Compare 1153s return self.visit(binop) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:531: in visit_BinOp 1153s op, op_class, left, right = self._maybe_transform_eq_ne(node) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:453: in _maybe_transform_eq_ne 1153s right = self.visit(node.right, side="right") 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:456: in visit_Subscript 1153s value = self.visit(node.value) 1153s /usr/lib/python3/dist-packages/pandas/core/computation/expr.py:411: in visit 1153s return visitor(node, **kwargs) 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s 1153s self = 1153s node = , kwargs = {}, attr = 'columns' 1153s value = , ctx = 1153s resolved = 'df' 1153s 1153s def visit_Attribute(self, node, **kwargs): 1153s attr = node.attr 1153s value = node.value 1153s 1153s ctx = type(node.ctx) 1153s if ctx == ast.Load: 1153s # resolve the value 1153s resolved = self.visit(value) 1153s 1153s # try to get the value to see if we are another expression 1153s try: 1153s resolved = resolved.value 1153s except AttributeError: 1153s pass 1153s 1153s try: 1153s return self.term_type(getattr(resolved, attr), self.env) 1153s except AttributeError: 1153s # something like datetime.datetime where scope is overridden 1153s if isinstance(value, ast.Name) and value.id == attr: 1153s return resolved 1153s 1153s > raise ValueError(f"Invalid Attribute context {ctx.__name__}") 1153s E ValueError: Invalid Attribute context Load 1153s 1153s /usr/lib/python3/dist-packages/pandas/core/computation/pytables.py:496: ValueError 1153s __________________ test_frame_setitem_dask_array_into_new_col __________________ 1153s @pytest.mark.xfail( 1153s condition=True,#not IS64, 1153s reason="ignoring https://bugs.debian.org/1094417 to unblock transition",#"dask has different nativesize-int vs int64 type rules", 1153s strict=False, 1153s ) 1153s def test_frame_setitem_dask_array_into_new_col(): 1153s # GH#47128 1153s 1153s # dask sets "compute.use_numexpr" to False, so catch the current value 1153s # and ensure to reset it afterwards to avoid impacting other tests 1153s olduse = pd.get_option("compute.use_numexpr") 1153s 1153s try: 1153s da = td.versioned_importorskip("dask.array") 1153s 1153s dda = da.array([1, 2]) 1153s df = DataFrame({"a": ["a", "b"]}) 1153s df["b"] = dda 1153s df["c"] = dda 1153s df.loc[[False, True], "b"] = 100 1153s result = df.loc[[1], :] 1153s expected = DataFrame({"a": ["b"], "b": [100], "c": [2]}, index=[1]) 1153s > tm.assert_frame_equal(result, expected) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:256: 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s 1153s left = array([100]), right = array([2]), err_msg = None 1153s 1153s def _raise(left, right, err_msg) -> NoReturn: 1153s if err_msg is None: 1153s if left.shape != right.shape: 1153s raise_assert_detail( 1153s obj, f"{obj} shapes are different", left.shape, right.shape 1153s ) 1153s 1153s diff = 0 1153s for left_arr, right_arr in zip(left, right): 1153s # count up differences 1153s if not array_equivalent(left_arr, right_arr, strict_nan=strict_nan): 1153s diff += 1 1153s 1153s diff = diff * 100.0 / left.size 1153s msg = f"{obj} values are different ({np.round(diff, 5)} %)" 1153s > raise_assert_detail(obj, msg, left, right, index_values=index_values) 1153s E AssertionError: DataFrame.iloc[:, 2] (column name="c") are different 1153s E 1153s E DataFrame.iloc[:, 2] (column name="c") values are different (100.0 %) 1153s E [index]: [1] 1153s E [left]: [100] 1153s E [right]: [2] 1153s 1153s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:684: AssertionError 1153s ________ TestDataFrameToXArray.test_to_xarray_index_types[datetime-tz] _________ 1153s self = 1153s index_flat = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1153s '2020-01-03 00:00:00-08:00', '... '2020-04-08 00:00:00-07:00', '2020-04-09 00:00:00-07:00'], 1153s dtype='datetime64[ns, US/Pacific]', freq='D') 1153s df = bar a b c ... f g h 1153s foo .....03 00:00:00-05:00 1153s 2020-01-04 00:00:00-08:00 d 4 6 ... d 2013-01-04 2013-01-04 00:00:00-05:00 1153s 1153s [4 rows x 8 columns] 1153s using_infer_string = False 1153s 1153s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1153s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1153s index = index_flat 1153s # MultiIndex is tested in test_to_xarray_with_multiindex 1153s if len(index) == 0: 1153s pytest.skip("Test doesn't make sense for empty index") 1153s 1153s from xarray import Dataset 1153s 1153s df.index = index[:4] 1153s df.index.name = "foo" 1153s df.columns.name = "bar" 1153s result = df.to_xarray() 1153s assert result.sizes["foo"] == 4 1153s assert len(result.coords) == 1 1153s assert len(result.data_vars) == 8 1153s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1153s assert isinstance(result, Dataset) 1153s 1153s # idempotency 1153s # datetimes w/tz are preserved 1153s # column names are lost 1153s expected = df.copy() 1153s # breaks in xarray >= 2024.10.0(?) 1153s # debug print 1153s r0 = result.to_dataframe() 1153s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1153s expected.columns.name = None 1153s > tm.assert_frame_equal(result.to_dataframe(), expected) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s 1153s left = Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 1153s 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 1153s dtype='object', name='foo') 1153s right = DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1153s '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 1153s dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 1153s obj = 'DataFrame.index' 1153s 1153s def _check_types(left, right, obj: str = "Index") -> None: 1153s if not exact: 1153s return 1153s 1153s > assert_class_equal(left, right, exact=exact, obj=obj) 1153s E AssertionError: DataFrame.index are different 1153s E 1153s E DataFrame.index classes are different 1153s E [left]: Index([2020-01-01 00:00:00-08:00, 2020-01-02 00:00:00-08:00, 1153s E 2020-01-03 00:00:00-08:00, 2020-01-04 00:00:00-08:00], 1153s E dtype='object', name='foo') 1153s E [right]: DatetimeIndex(['2020-01-01 00:00:00-08:00', '2020-01-02 00:00:00-08:00', 1153s E '2020-01-03 00:00:00-08:00', '2020-01-04 00:00:00-08:00'], 1153s E dtype='datetime64[ns, US/Pacific]', name='foo', freq='D') 1153s 1153s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 1153s ________ TestDataFrameToXArray.test_to_xarray_index_types[bool-object] _________ 1153s self = 1153s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='object') 1153s df = bar a b c d e f g h 1153s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1153s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1153s using_infer_string = False 1153s 1153s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1153s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1153s index = index_flat 1153s # MultiIndex is tested in test_to_xarray_with_multiindex 1153s if len(index) == 0: 1153s pytest.skip("Test doesn't make sense for empty index") 1153s 1153s from xarray import Dataset 1153s 1153s df.index = index[:4] 1153s df.index.name = "foo" 1153s df.columns.name = "bar" 1153s result = df.to_xarray() 1153s assert result.sizes["foo"] == 4 1153s assert len(result.coords) == 1 1153s assert len(result.data_vars) == 8 1153s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1153s assert isinstance(result, Dataset) 1153s 1153s # idempotency 1153s # datetimes w/tz are preserved 1153s # column names are lost 1153s expected = df.copy() 1153s # breaks in xarray >= 2024.10.0(?) 1153s # debug print 1153s r0 = result.to_dataframe() 1153s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1153s expected.columns.name = None 1153s > tm.assert_frame_equal(result.to_dataframe(), expected) 1153s E AssertionError: DataFrame are different 1153s E 1153s E DataFrame shape mismatch 1153s E [left]: (8, 8) 1153s E [right]: (4, 8) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1153s _________ TestDataFrameToXArray.test_to_xarray_index_types[bool-dtype] _________ 1153s self = 1153s index_flat = Index([True, False, True, False, True, False, True, False, True, False], dtype='bool') 1153s df = bar a b c d e f g h 1153s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1153s False d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1153s using_infer_string = False 1153s 1153s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1153s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1153s index = index_flat 1153s # MultiIndex is tested in test_to_xarray_with_multiindex 1153s if len(index) == 0: 1153s pytest.skip("Test doesn't make sense for empty index") 1153s 1153s from xarray import Dataset 1153s 1153s df.index = index[:4] 1153s df.index.name = "foo" 1153s df.columns.name = "bar" 1153s result = df.to_xarray() 1153s assert result.sizes["foo"] == 4 1153s assert len(result.coords) == 1 1153s assert len(result.data_vars) == 8 1153s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1153s assert isinstance(result, Dataset) 1153s 1153s # idempotency 1153s # datetimes w/tz are preserved 1153s # column names are lost 1153s expected = df.copy() 1153s # breaks in xarray >= 2024.10.0(?) 1153s # debug print 1153s r0 = result.to_dataframe() 1153s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1153s expected.columns.name = None 1153s > tm.assert_frame_equal(result.to_dataframe(), expected) 1153s E AssertionError: DataFrame are different 1153s E 1153s E DataFrame shape mismatch 1153s E [left]: (8, 8) 1153s E [right]: (4, 8) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1153s ________ TestDataFrameToXArray.test_to_xarray_index_types[categorical] _________ 1153s self = 1153s index_flat = CategoricalIndex(['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 1153s 'a', 'b', 'c', 'd', 'a... 'a', 'b', 'c', 'd'], 1153s categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category') 1153s df = bar a b c d e f g h 1153s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1153s d d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1153s using_infer_string = False 1153s 1153s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1153s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1153s index = index_flat 1153s # MultiIndex is tested in test_to_xarray_with_multiindex 1153s if len(index) == 0: 1153s pytest.skip("Test doesn't make sense for empty index") 1153s 1153s from xarray import Dataset 1153s 1153s df.index = index[:4] 1153s df.index.name = "foo" 1153s df.columns.name = "bar" 1153s result = df.to_xarray() 1153s assert result.sizes["foo"] == 4 1153s assert len(result.coords) == 1 1153s assert len(result.data_vars) == 8 1153s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1153s assert isinstance(result, Dataset) 1153s 1153s # idempotency 1153s # datetimes w/tz are preserved 1153s # column names are lost 1153s expected = df.copy() 1153s # breaks in xarray >= 2024.10.0(?) 1153s # debug print 1153s r0 = result.to_dataframe() 1153s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1153s expected.columns.name = None 1153s > tm.assert_frame_equal(result.to_dataframe(), expected) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s 1153s left = Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 1153s right = CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 1153s obj = 'DataFrame.index' 1153s 1153s def _check_types(left, right, obj: str = "Index") -> None: 1153s if not exact: 1153s return 1153s 1153s > assert_class_equal(left, right, exact=exact, obj=obj) 1153s E AssertionError: DataFrame.index are different 1153s E 1153s E DataFrame.index classes are different 1153s E [left]: Index(['a', 'b', 'c', 'd'], dtype='object', name='foo') 1153s E [right]: CategoricalIndex(['a', 'b', 'c', 'd'], categories=['a', 'b', 'c', 'd'], ordered=False, dtype='category', name='foo') 1153s 1153s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:235: AssertionError 1153s __________ TestDataFrameToXArray.test_to_xarray_index_types[repeats] ___________ 1153s self = 1153s index_flat = Index([0, 0, 1, 1, 2, 2], dtype='int64') 1153s df = bar a b c d e f g h 1153s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1153s 1 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1153s using_infer_string = False 1153s 1153s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1153s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1153s index = index_flat 1153s # MultiIndex is tested in test_to_xarray_with_multiindex 1153s if len(index) == 0: 1153s pytest.skip("Test doesn't make sense for empty index") 1153s 1153s from xarray import Dataset 1153s 1153s df.index = index[:4] 1153s df.index.name = "foo" 1153s df.columns.name = "bar" 1153s result = df.to_xarray() 1153s assert result.sizes["foo"] == 4 1153s assert len(result.coords) == 1 1153s assert len(result.data_vars) == 8 1153s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1153s assert isinstance(result, Dataset) 1153s 1153s # idempotency 1153s # datetimes w/tz are preserved 1153s # column names are lost 1153s expected = df.copy() 1153s # breaks in xarray >= 2024.10.0(?) 1153s # debug print 1153s r0 = result.to_dataframe() 1153s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1153s expected.columns.name = None 1153s > tm.assert_frame_equal(result.to_dataframe(), expected) 1153s E AssertionError: DataFrame are different 1153s E 1153s E DataFrame shape mismatch 1153s E [left]: (8, 8) 1153s E [right]: (4, 8) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1153s ________ TestDataFrameToXArray.test_to_xarray_index_types[nullable_int] ________ 1153s self = 1153s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1153s 18, 19, 20, 21, 22, 23, 24, 25, ...7, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 1153s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 1153s dtype='Int64') 1153s df = bar a b c d e f g h 1153s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1153s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1153s using_infer_string = False 1153s 1153s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1153s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1153s index = index_flat 1153s # MultiIndex is tested in test_to_xarray_with_multiindex 1153s if len(index) == 0: 1153s pytest.skip("Test doesn't make sense for empty index") 1153s 1153s from xarray import Dataset 1153s 1153s df.index = index[:4] 1153s df.index.name = "foo" 1153s df.columns.name = "bar" 1153s result = df.to_xarray() 1153s assert result.sizes["foo"] == 4 1153s assert len(result.coords) == 1 1153s assert len(result.data_vars) == 8 1153s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1153s assert isinstance(result, Dataset) 1153s 1153s # idempotency 1153s # datetimes w/tz are preserved 1153s # column names are lost 1153s expected = df.copy() 1153s # breaks in xarray >= 2024.10.0(?) 1153s # debug print 1153s r0 = result.to_dataframe() 1153s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1153s expected.columns.name = None 1153s > tm.assert_frame_equal(result.to_dataframe(), expected) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s 1153s left = Index([0, 1, 2, 3], dtype='object', name='foo') 1153s right = Index([0, 1, 2, 3], dtype='Int64', name='foo'), obj = 'DataFrame.index' 1153s 1153s def _check_types(left, right, obj: str = "Index") -> None: 1153s if not exact: 1153s return 1153s 1153s assert_class_equal(left, right, exact=exact, obj=obj) 1153s assert_attr_equal("inferred_type", left, right, obj=obj) 1153s 1153s # Skip exact dtype checking when `check_categorical` is False 1153s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1153s right.dtype, CategoricalDtype 1153s ): 1153s if check_categorical: 1153s assert_attr_equal("dtype", left, right, obj=obj) 1153s assert_index_equal(left.categories, right.categories, exact=exact) 1153s return 1153s 1153s > assert_attr_equal("dtype", left, right, obj=obj) 1153s E AssertionError: DataFrame.index are different 1153s E 1153s E Attribute "dtype" are different 1153s E [left]: object 1153s E [right]: Int64 1153s 1153s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1153s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_uint] ________ 1153s self = 1153s index_flat = Index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 1153s 18, 19, 20, 21, 22, 23, 24, 25, ..., 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 1153s 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], 1153s dtype='UInt16') 1153s df = bar a b c d e f g h 1153s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1153s 3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1153s using_infer_string = False 1153s 1153s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1153s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1153s index = index_flat 1153s # MultiIndex is tested in test_to_xarray_with_multiindex 1153s if len(index) == 0: 1153s pytest.skip("Test doesn't make sense for empty index") 1153s 1153s from xarray import Dataset 1153s 1153s df.index = index[:4] 1153s df.index.name = "foo" 1153s df.columns.name = "bar" 1153s result = df.to_xarray() 1153s assert result.sizes["foo"] == 4 1153s assert len(result.coords) == 1 1153s assert len(result.data_vars) == 8 1153s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1153s assert isinstance(result, Dataset) 1153s 1153s # idempotency 1153s # datetimes w/tz are preserved 1153s # column names are lost 1153s expected = df.copy() 1153s # breaks in xarray >= 2024.10.0(?) 1153s # debug print 1153s r0 = result.to_dataframe() 1153s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1153s expected.columns.name = None 1153s > tm.assert_frame_equal(result.to_dataframe(), expected) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s 1153s left = Index([0, 1, 2, 3], dtype='object', name='foo') 1153s right = Index([0, 1, 2, 3], dtype='UInt16', name='foo'), obj = 'DataFrame.index' 1153s 1153s def _check_types(left, right, obj: str = "Index") -> None: 1153s if not exact: 1153s return 1153s 1153s assert_class_equal(left, right, exact=exact, obj=obj) 1153s assert_attr_equal("inferred_type", left, right, obj=obj) 1153s 1153s # Skip exact dtype checking when `check_categorical` is False 1153s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1153s right.dtype, CategoricalDtype 1153s ): 1153s if check_categorical: 1153s assert_attr_equal("dtype", left, right, obj=obj) 1153s assert_index_equal(left.categories, right.categories, exact=exact) 1153s return 1153s 1153s > assert_attr_equal("dtype", left, right, obj=obj) 1153s E AssertionError: DataFrame.index are different 1153s E 1153s E Attribute "dtype" are different 1153s E [left]: object 1153s E [right]: UInt16 1153s 1153s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1153s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_float] _______ 1153s self = 1153s 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, 1153s 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, 1153s 96.0, 97.0, 98.0, 99.0], 1153s dtype='Float32') 1153s df = bar a b c d e f g h 1153s foo ... 5 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1153s 3.0 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1153s using_infer_string = False 1153s 1153s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1153s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1153s index = index_flat 1153s # MultiIndex is tested in test_to_xarray_with_multiindex 1153s if len(index) == 0: 1153s pytest.skip("Test doesn't make sense for empty index") 1153s 1153s from xarray import Dataset 1153s 1153s df.index = index[:4] 1153s df.index.name = "foo" 1153s df.columns.name = "bar" 1153s result = df.to_xarray() 1153s assert result.sizes["foo"] == 4 1153s assert len(result.coords) == 1 1153s assert len(result.data_vars) == 8 1153s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1153s assert isinstance(result, Dataset) 1153s 1153s # idempotency 1153s # datetimes w/tz are preserved 1153s # column names are lost 1153s expected = df.copy() 1153s # breaks in xarray >= 2024.10.0(?) 1153s # debug print 1153s r0 = result.to_dataframe() 1153s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1153s expected.columns.name = None 1153s > tm.assert_frame_equal(result.to_dataframe(), expected) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s 1153s left = Index([0.0, 1.0, 2.0, 3.0], dtype='object', name='foo') 1153s right = Index([0.0, 1.0, 2.0, 3.0], dtype='Float32', name='foo') 1153s obj = 'DataFrame.index' 1153s 1153s def _check_types(left, right, obj: str = "Index") -> None: 1153s if not exact: 1153s return 1153s 1153s assert_class_equal(left, right, exact=exact, obj=obj) 1153s assert_attr_equal("inferred_type", left, right, obj=obj) 1153s 1153s # Skip exact dtype checking when `check_categorical` is False 1153s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1153s right.dtype, CategoricalDtype 1153s ): 1153s if check_categorical: 1153s assert_attr_equal("dtype", left, right, obj=obj) 1153s assert_index_equal(left.categories, right.categories, exact=exact) 1153s return 1153s 1153s > assert_attr_equal("dtype", left, right, obj=obj) 1153s E AssertionError: DataFrame.index are different 1153s E 1153s E Attribute "dtype" are different 1153s E [left]: object 1153s E [right]: Float32 1153s 1153s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1153s _______ TestDataFrameToXArray.test_to_xarray_index_types[nullable_bool] ________ 1153s self = 1153s index_flat = Index([False, True, True, True, True, True, True, True, True, True, 1153s True, True, True, True, True,...rue, True, True, 1153s True, True, True, True, True, True, True, True, True, True], 1153s dtype='boolean') 1153s df = bar a b c d e f g h 1153s foo ... 6.0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1153s True d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1153s using_infer_string = False 1153s 1153s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1153s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1153s index = index_flat 1153s # MultiIndex is tested in test_to_xarray_with_multiindex 1153s if len(index) == 0: 1153s pytest.skip("Test doesn't make sense for empty index") 1153s 1153s from xarray import Dataset 1153s 1153s df.index = index[:4] 1153s df.index.name = "foo" 1153s df.columns.name = "bar" 1153s result = df.to_xarray() 1153s assert result.sizes["foo"] == 4 1153s assert len(result.coords) == 1 1153s assert len(result.data_vars) == 8 1153s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1153s assert isinstance(result, Dataset) 1153s 1153s # idempotency 1153s # datetimes w/tz are preserved 1153s # column names are lost 1153s expected = df.copy() 1153s # breaks in xarray >= 2024.10.0(?) 1153s # debug print 1153s r0 = result.to_dataframe() 1153s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1153s expected.columns.name = None 1153s > tm.assert_frame_equal(result.to_dataframe(), expected) 1153s E AssertionError: DataFrame are different 1153s E 1153s E DataFrame shape mismatch 1153s E [left]: (10, 8) 1153s E [right]: (4, 8) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: AssertionError 1153s _______ TestDataFrameToXArray.test_to_xarray_index_types[string-python] ________ 1153s self = 1153s index_flat = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3', 'pandas_4', 'pandas_5', 1153s 'pandas_6', 'pandas_7', 'pandas_...pandas_93', 'pandas_94', 'pandas_95', 1153s 'pandas_96', 'pandas_97', 'pandas_98', 'pandas_99'], 1153s dtype='string') 1153s df = bar a b c d e f g h 1153s foo ....0 True c 2013-01-03 2013-01-03 00:00:00-05:00 1153s pandas_3 d 4 6 7.0 False d 2013-01-04 2013-01-04 00:00:00-05:00 1153s using_infer_string = False 1153s 1153s @pytest.mark.xfail(condition=True,reason="ignoring https://bugs.debian.org/1088988 to unblock transition",strict=False) 1153s def test_to_xarray_index_types(self, index_flat, df, using_infer_string): 1153s index = index_flat 1153s # MultiIndex is tested in test_to_xarray_with_multiindex 1153s if len(index) == 0: 1153s pytest.skip("Test doesn't make sense for empty index") 1153s 1153s from xarray import Dataset 1153s 1153s df.index = index[:4] 1153s df.index.name = "foo" 1153s df.columns.name = "bar" 1153s result = df.to_xarray() 1153s assert result.sizes["foo"] == 4 1153s assert len(result.coords) == 1 1153s assert len(result.data_vars) == 8 1153s tm.assert_almost_equal(list(result.coords.keys()), ["foo"]) 1153s assert isinstance(result, Dataset) 1153s 1153s # idempotency 1153s # datetimes w/tz are preserved 1153s # column names are lost 1153s expected = df.copy() 1153s # breaks in xarray >= 2024.10.0(?) 1153s # debug print 1153s r0 = result.to_dataframe() 1153s print("expected",expected, expected.index, expected.dtypes, "actual",result, r0, r0.index, r0.dtypes,sep='\n') 1153s expected.columns.name = None 1153s > tm.assert_frame_equal(result.to_dataframe(), expected) 1153s 1153s /usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py:61: 1153s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1153s 1153s left = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='object', name='foo') 1153s right = Index(['pandas_0', 'pandas_1', 'pandas_2', 'pandas_3'], dtype='string', name='foo') 1153s obj = 'DataFrame.index' 1153s 1153s def _check_types(left, right, obj: str = "Index") -> None: 1153s if not exact: 1153s return 1153s 1153s assert_class_equal(left, right, exact=exact, obj=obj) 1153s assert_attr_equal("inferred_type", left, right, obj=obj) 1153s 1153s # Skip exact dtype checking when `check_categorical` is False 1153s if isinstance(left.dtype, CategoricalDtype) and isinstance( 1153s right.dtype, CategoricalDtype 1153s ): 1153s if check_categorical: 1153s assert_attr_equal("dtype", left, right, obj=obj) 1153s assert_index_equal(left.categories, right.categories, exact=exact) 1153s return 1153s 1153s > assert_attr_equal("dtype", left, right, obj=obj) 1153s E AssertionError: DataFrame.index are different 1153s E 1153s E Attribute "dtype" are different 1153s E [left]: object 1153s E [right]: string[python] 1153s 1153s /usr/lib/python3/dist-packages/pandas/_testing/asserters.py:247: AssertionError 1153s =============================== warnings summary =============================== 1153s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py:39 1153s /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 1153s pytestmark = pytest.mark.single_cpu 1153s 1153s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py:30 1153s /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 1153s pytestmark = pytest.mark.single_cpu 1153s 1153s ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py:39 1153s /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 1153s pytestmark = pytest.mark.single_cpu 1153s 1153s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:119 1153s /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 1153s @pytest.mark.single_cpu 1153s 1153s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:125 1153s /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 1153s @pytest.mark.single_cpu 1153s 1153s ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py:196 1153s /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 1153s @pytest.mark.single_cpu 1153s 1153s io/pytables/test_file_handling.py: 191 warnings 1153s io/pytables/test_append.py: 21 warnings 1153s io/pytables/test_store.py: 66 warnings 1153s test_downstream.py: 26 warnings 1153s generic/test_to_xarray.py: 62 warnings 1153s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=17269) is multi-threaded, use of fork() may lead to deadlocks in the child. 1153s pid = os.fork() 1153s 1153s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1153s /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-6hj1qvce' 1153s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1153s 1153s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 1153s /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-d7sxshyh' 1153s config.cache.set("cache/lastfailed", self.lastfailed) 1153s 1153s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1153s /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-92dbdxul' 1153s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1153s 1153s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1153s =========================== short test summary info ============================ 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-1] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-2] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-3] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-4] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-5] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-6] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-7] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-8] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_file_handling.py::test_complibs[blosc2-9] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_append.py::test_append_frame_column_oriented 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/pytables/test_store.py::test_select_filter_corner 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/test_downstream.py::test_frame_setitem_dask_array_into_new_col 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[datetime-tz] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-object] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[bool-dtype] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[categorical] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[repeats] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_int] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_uint] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_float] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[nullable_bool] 1153s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/generic/test_to_xarray.py::TestDataFrameToXArray::test_to_xarray_index_types[string-python] 1153s =========== 22 failed, 335 passed, 9 skipped, 375 warnings in 22.53s =========== 1153s pymysql/psycopg2 tests, which do not work in this test environment 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)) 1154s ============================= test session starts ============================== 1154s platform linux -- Python 3.13.4, pytest-8.3.5, pluggy-1.5.0 1154s PyQt5 5.15.11 -- Qt runtime 5.15.15 -- Qt compiled 5.15.15 1154s rootdir: /usr/lib/python3/dist-packages/pandas/tests 1154s plugins: localserver-0.9.0.post0, asyncio-0.25.1, hypothesis-6.130.5, qt-4.4.0, forked-1.6.0, xdist-3.6.1, typeguard-4.4.2 1154s asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None 1154s collected 2513 items 1154s 1726s ../../../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................ 1746s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py ..................................................................................................................................................................................................................................ssssssss......................................................................................................................................................................................................................................................................................................................................................xx..........................................................................................................................................................................................................................................................................................................................................................................ssssssssss............................ 1746s 1746s ==================================== ERRORS ==================================== 1746s _______ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_engine] _______ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s ________ ERROR at teardown of test_dataframe_to_sql[mysql_pymysql_conn] ________ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s ____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_engine] ____ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _____ ERROR at teardown of test_dataframe_to_sql[postgresql_psycopg2_conn] _____ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s ____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_engine] ____ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _____ ERROR at teardown of test_dataframe_to_sql_empty[mysql_pymysql_conn] _____ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_engine] _ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s __ ERROR at teardown of test_dataframe_to_sql_empty[postgresql_psycopg2_conn] __ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _________ ERROR at teardown of test_to_sql[None-mysql_pymysql_engine] __________ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s __________ ERROR at teardown of test_to_sql[None-mysql_pymysql_conn] ___________ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s ______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_engine] _______ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _______ ERROR at teardown of test_to_sql[None-postgresql_psycopg2_conn] ________ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_engine] _________ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s __________ ERROR at teardown of test_to_sql[multi-mysql_pymysql_conn] __________ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s ______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_engine] ______ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _______ ERROR at teardown of test_to_sql[multi-postgresql_psycopg2_conn] _______ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s ____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_engine] ____ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _____ ERROR at teardown of test_to_sql_exist[replace-1-mysql_pymysql_conn] _____ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_engine] _ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s __ ERROR at teardown of test_to_sql_exist[replace-1-postgresql_psycopg2_conn] __ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s ____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_engine] _____ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _____ ERROR at teardown of test_to_sql_exist[append-2-mysql_pymysql_conn] ______ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_engine] __ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s __ ERROR at teardown of test_to_sql_exist[append-2-postgresql_psycopg2_conn] ___ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s ______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_engine] _______ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _______ ERROR at teardown of test_to_sql_exist_fail[mysql_pymysql_conn] ________ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s ___ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_engine] ____ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s ____ ERROR at teardown of test_to_sql_exist_fail[postgresql_psycopg2_conn] _____ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _____ ERROR at teardown of test_read_iris_query[mysql_pymysql_engine_iris] _____ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s ______ ERROR at teardown of test_read_iris_query[mysql_pymysql_conn_iris] ______ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s __ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_engine_iris] __ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s ___ ERROR at teardown of test_read_iris_query[postgresql_psycopg2_conn_iris] ___ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_engine_iris] _ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_chunksize[mysql_pymysql_conn_iris] _ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] _ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] _ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] _ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] _ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] _ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _ ERROR at teardown of test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] _ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _____ ERROR at teardown of test_read_iris_table[mysql_pymysql_engine_iris] _____ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s ______ ERROR at teardown of test_read_iris_table[mysql_pymysql_conn_iris] ______ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s __ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_engine_iris] __ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s ___ ERROR at teardown of test_read_iris_table[postgresql_psycopg2_conn_iris] ___ 1746s self = 1746s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1746s connection = None, _has_events = None, _allow_revalidate = True 1746s _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def postgresql_psycopg2_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s td.versioned_importorskip("psycopg2") 1746s engine = sqlalchemy.create_engine( 1746s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1746s connection_factory = None, cursor_factory = None 1746s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1746s kwasync = {} 1746s 1746s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1746s """ 1746s Create a new database connection. 1746s 1746s The connection parameters can be specified as a string: 1746s 1746s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1746s 1746s or using a set of keyword arguments: 1746s 1746s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1746s 1746s Or as a mix of both. The basic connection parameters are: 1746s 1746s - *dbname*: the database name 1746s - *database*: the database name (only as keyword argument) 1746s - *user*: user name used to authenticate 1746s - *password*: password used to authenticate 1746s - *host*: database host address (defaults to UNIX socket if not provided) 1746s - *port*: connection port number (defaults to 5432 if not provided) 1746s 1746s Using the *connection_factory* parameter a different class or connections 1746s factory can be specified. It should be a callable object taking a dsn 1746s argument. 1746s 1746s Using the *cursor_factory* parameter, a new default cursor factory will be 1746s used by cursor(). 1746s 1746s Using *async*=True an asynchronous connection will be created. *async_* is 1746s a valid alias (for Python versions where ``async`` is a keyword). 1746s 1746s Any other keyword parameter will be passed to the underlying client 1746s library: the list of supported parameters depends on the library version. 1746s 1746s """ 1746s kwasync = {} 1746s if 'async' in kwargs: 1746s kwasync['async'] = kwargs.pop('async') 1746s if 'async_' in kwargs: 1746s kwasync['async_'] = kwargs.pop('async_') 1746s 1746s dsn = _ext.make_dsn(dsn, **kwargs) 1746s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1746s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1746s E Is the server running on that host and accepting TCP/IP connections? 1746s E 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1746s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_engine_iris] _ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1746s A host of '' or port 0 tells the OS to use the default. When a connection 1746s cannot be created, raises the last error if *all_errors* is False, 1746s and an ExceptionGroup of all errors if *all_errors* is True. 1746s """ 1746s 1746s host, port = address 1746s exceptions = [] 1746s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1746s af, socktype, proto, canonname, sa = res 1746s sock = None 1746s try: 1746s sock = socket(af, socktype, proto) 1746s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1746s sock.settimeout(timeout) 1746s if source_address: 1746s sock.bind(source_address) 1746s > sock.connect(sa) 1746s E ConnectionRefusedError: [Errno 111] Connection refused 1746s 1746s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1746s 1746s During handling of the above exception, another exception occurred: 1746s 1746s self = 1746s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1746s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1746s 1746s def __init__( 1746s self, 1746s engine: Engine, 1746s connection: Optional[PoolProxiedConnection] = None, 1746s _has_events: Optional[bool] = None, 1746s _allow_revalidate: bool = True, 1746s _allow_autobegin: bool = True, 1746s ): 1746s """Construct a new Connection.""" 1746s self.engine = engine 1746s self.dialect = dialect = engine.dialect 1746s 1746s if connection is None: 1746s try: 1746s > self._dbapi_connection = engine.raw_connection() 1746s 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s 1746s The above exception was the direct cause of the following exception: 1746s 1746s @pytest.fixture 1746s def mysql_pymysql_engine(): 1746s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1746s pymysql = td.versioned_importorskip("pymysql") 1746s engine = sqlalchemy.create_engine( 1746s "mysql+pymysql://root@localhost:3306/pandas", 1746s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1746s poolclass=sqlalchemy.pool.NullPool, 1746s ) 1746s yield engine 1746s > for view in get_all_views(engine): 1746s 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1746s return inspect(conn).get_view_names() 1746s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1746s ret = reg(subject) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1746s return Inspector._construct(Inspector._init_engine, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1746s init(self, bind) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1746s engine.connect().close() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1746s return self._connection_cls(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1746s Connection._handle_dbapi_exception_noconnection( 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1746s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1746s self._dbapi_connection = engine.raw_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1746s return self.pool.connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1746s return _ConnectionFairy._checkout(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1746s fairy = _ConnectionRecord.checkout(pool) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1746s rec = pool._do_get() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1746s return self._create_connection() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1746s return _ConnectionRecord(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1746s self.__connect() 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1746s with util.safe_reraise(): 1746s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1746s raise exc_value.with_traceback(exc_tb) 1746s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1746s self.dbapi_connection = connection = pool._invoke_creator(self) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1746s return dialect.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1746s return self.loaded_dbapi.connect(*cargs, **cparams) 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1746s self.connect() 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s break 1746s except OSError as e: 1746s if e.errno == errno.EINTR: 1746s continue 1746s raise 1746s self.host_info = "socket %s:%d" % (self.host, self.port) 1746s if DEBUG: 1746s print("connected using socket") 1746s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1746s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1746s sock.settimeout(None) 1746s 1746s self._sock = sock 1746s self._rfile = sock.makefile("rb") 1746s self._next_seq_id = 0 1746s 1746s self._get_server_information() 1746s self._request_authentication() 1746s 1746s # Send "SET NAMES" query on init for: 1746s # - Ensure charaset (and collation) is set to the server. 1746s # - collation_id in handshake packet may be ignored. 1746s # - If collation is not specified, we don't know what is server's 1746s # default collation for the charset. For example, default collation 1746s # of utf8mb4 is: 1746s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1746s # - MySQL 8.0: utf8mb4_0900_ai_ci 1746s # 1746s # Reference: 1746s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1746s # - https://github.com/wagtail/wagtail/issues/9477 1746s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1746s self.set_character_set(self.charset, self.collation) 1746s 1746s if self.sql_mode is not None: 1746s c = self.cursor() 1746s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1746s c.close() 1746s 1746s if self.init_command is not None: 1746s c = self.cursor() 1746s c.execute(self.init_command) 1746s c.close() 1746s 1746s if self.autocommit_mode is not None: 1746s self.autocommit(self.autocommit_mode) 1746s except BaseException as e: 1746s self._rfile = None 1746s if sock is not None: 1746s try: 1746s sock.close() 1746s except: # noqa 1746s pass 1746s 1746s if isinstance(e, (OSError, IOError)): 1746s exc = err.OperationalError( 1746s CR.CR_CONN_HOST_ERROR, 1746s f"Can't connect to MySQL server on {self.host!r} ({e})", 1746s ) 1746s # Keep original exception and traceback to investigate error. 1746s exc.original_exception = e 1746s exc.traceback = traceback.format_exc() 1746s if DEBUG: 1746s print(exc.traceback) 1746s > raise exc 1746s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1746s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1746s _ ERROR at teardown of test_read_iris_table_chunksize[mysql_pymysql_conn_iris] _ 1746s self = , sock = None 1746s 1746s def connect(self, sock=None): 1746s self._closed = False 1746s try: 1746s if sock is None: 1746s if self.unix_socket: 1746s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1746s sock.settimeout(self.connect_timeout) 1746s sock.connect(self.unix_socket) 1746s self.host_info = "Localhost via UNIX socket" 1746s self._secure = True 1746s if DEBUG: 1746s print("connected using unix_socket") 1746s else: 1746s kwargs = {} 1746s if self.bind_address is not None: 1746s kwargs["source_address"] = (self.bind_address, 0) 1746s while True: 1746s try: 1746s > sock = socket.create_connection( 1746s (self.host, self.port), self.connect_timeout, **kwargs 1746s ) 1746s 1746s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s /usr/lib/python3.13/socket.py:864: in create_connection 1746s raise exceptions[0] 1746s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1746s 1746s address = ('localhost', 3306), timeout = 10, source_address = None 1746s 1746s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1746s source_address=None, *, all_errors=False): 1746s """Connect to *address* and return the socket object. 1746s 1746s Convenience function. Connect to *address* (a 2-tuple ``(host, 1746s port)``) and return the socket object. Passing the optional 1746s *timeout* parameter will set the timeout on the socket instance 1746s before attempting to connect. If no *timeout* is supplied, the 1746s global default timeout setting returned by :func:`getdefaulttimeout` 1746s is used. If *source_address* is set it must be a tuple of (host, port) 1746s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _______ ERROR at teardown of test_to_sql_callable[mysql_pymysql_engine] ________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ________ ERROR at teardown of test_to_sql_callable[mysql_pymysql_conn] _________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_engine] _____ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _____ ERROR at teardown of test_to_sql_callable[postgresql_psycopg2_conn] ______ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_default_type_conversion[mysql_pymysql_conn_types] __ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_default_type_conversion[postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ________ ERROR at teardown of test_read_procedure[mysql_pymysql_engine] ________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _________ ERROR at teardown of test_read_procedure[mysql_pymysql_conn] _________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_to_sql_on_public_schema[postgresql_psycopg2_conn] __ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_engine] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_insertion_method_on_conflict_update[mysql_pymysql_conn] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ___ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_engine] ___ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ____ ERROR at teardown of test_read_view_postgres[postgresql_psycopg2_conn] ____ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_engine_iris] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s __ ERROR at teardown of test_read_sql_iris_parameter[mysql_pymysql_conn_iris] __ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_engine_iris] ____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _____ ERROR at teardown of test_api_read_sql_view[mysql_pymysql_conn_iris] _____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_engine_iris] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s __ ERROR at teardown of test_api_read_sql_view[postgresql_psycopg2_conn_iris] __ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s __________ ERROR at teardown of test_api_to_sql[mysql_pymysql_engine] __________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ___________ ERROR at teardown of test_api_to_sql[mysql_pymysql_conn] ___________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _______ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_engine] _______ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ________ ERROR at teardown of test_api_to_sql[postgresql_psycopg2_conn] ________ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _______ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_engine] ________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ________ ERROR at teardown of test_api_to_sql_fail[mysql_pymysql_conn] _________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_engine] _____ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _____ ERROR at teardown of test_api_to_sql_fail[postgresql_psycopg2_conn] ______ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_engine] ______ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _______ ERROR at teardown of test_api_to_sql_replace[mysql_pymysql_conn] _______ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ___ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_engine] ___ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ____ ERROR at teardown of test_api_to_sql_replace[postgresql_psycopg2_conn] ____ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_engine] _______ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _______ ERROR at teardown of test_api_to_sql_append[mysql_pymysql_conn] ________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ___ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_engine] ____ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ____ ERROR at teardown of test_api_to_sql_append[postgresql_psycopg2_conn] _____ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ___ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_engine] ____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ____ ERROR at teardown of test_api_to_sql_type_mapping[mysql_pymysql_conn] _____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_type_mapping[postgresql_psycopg2_conn] __ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_engine] _______ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _______ ERROR at teardown of test_api_to_sql_series[mysql_pymysql_conn] ________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ___ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_engine] ____ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ____ ERROR at teardown of test_api_to_sql_series[postgresql_psycopg2_conn] _____ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_engine] _________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _________ ERROR at teardown of test_api_roundtrip[mysql_pymysql_conn] __________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _____ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_engine] ______ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ______ ERROR at teardown of test_api_roundtrip[postgresql_psycopg2_conn] _______ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ___ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_engine] ____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ____ ERROR at teardown of test_api_roundtrip_chunksize[mysql_pymysql_conn] _____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_roundtrip_chunksize[postgresql_psycopg2_conn] __ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _____ ERROR at teardown of test_api_execute_sql[mysql_pymysql_engine_iris] _____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ______ ERROR at teardown of test_api_execute_sql[mysql_pymysql_conn_iris] ______ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s __ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_engine_iris] __ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ___ ERROR at teardown of test_api_execute_sql[postgresql_psycopg2_conn_iris] ___ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_engine_types] ____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _____ ERROR at teardown of test_api_date_parsing[mysql_pymysql_conn_types] _____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s __ ERROR at teardown of test_api_date_parsing[postgresql_psycopg2_conn_types] __ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ___ ERROR at teardown of test_api_date_and_index[mysql_pymysql_engine_types] ___ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ____ ERROR at teardown of test_api_date_and_index[mysql_pymysql_conn_types] ____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_engine_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_date_and_index[postgresql_psycopg2_conn_types] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ________ ERROR at teardown of test_api_timedelta[mysql_pymysql_engine] _________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _________ ERROR at teardown of test_api_timedelta[mysql_pymysql_conn] __________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _____ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_engine] ______ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ______ ERROR at teardown of test_api_timedelta[postgresql_psycopg2_conn] _______ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_engine] ______ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _______ ERROR at teardown of test_api_complex_raises[mysql_pymysql_conn] _______ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ___ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_engine] ___ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ____ ERROR at teardown of test_api_complex_raises[postgresql_psycopg2_conn] ____ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] _ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ___ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_engine] ___ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ____ ERROR at teardown of test_api_multiindex_roundtrip[mysql_pymysql_conn] ____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_multiindex_roundtrip[postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ___ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_engine] ____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ____ ERROR at teardown of test_api_dtype_argument[None-mysql_pymysql_conn] _____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_dtype_argument[None-postgresql_psycopg2_conn] __ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_engine] ____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _____ ERROR at teardown of test_api_dtype_argument[int-mysql_pymysql_conn] _____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s __ ERROR at teardown of test_api_dtype_argument[int-postgresql_psycopg2_conn] __ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ___ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_engine] ___ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ____ ERROR at teardown of test_api_dtype_argument[float-mysql_pymysql_conn] ____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_dtype_argument[float-postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s __ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_engine] ___ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s ___ ERROR at teardown of test_api_dtype_argument[dtype3-mysql_pymysql_conn] ____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s _ ERROR at teardown of test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] _ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_engine] _____ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _____ ERROR at teardown of test_api_integer_col_names[mysql_pymysql_conn] ______ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s > sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3.13/socket.py:864: in create_connection 1747s raise exceptions[0] 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s address = ('localhost', 3306), timeout = 10, source_address = None 1747s 1747s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1747s source_address=None, *, all_errors=False): 1747s """Connect to *address* and return the socket object. 1747s 1747s Convenience function. Connect to *address* (a 2-tuple ``(host, 1747s port)``) and return the socket object. Passing the optional 1747s *timeout* parameter will set the timeout on the socket instance 1747s before attempting to connect. If no *timeout* is supplied, the 1747s global default timeout setting returned by :func:`getdefaulttimeout` 1747s is used. If *source_address* is set it must be a tuple of (host, port) 1747s for the socket to bind as a source address before making the connection. 1747s A host of '' or port 0 tells the OS to use the default. When a connection 1747s cannot be created, raises the last error if *all_errors* is False, 1747s and an ExceptionGroup of all errors if *all_errors* is True. 1747s """ 1747s 1747s host, port = address 1747s exceptions = [] 1747s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1747s af, socktype, proto, canonname, sa = res 1747s sock = None 1747s try: 1747s sock = socket(af, socktype, proto) 1747s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1747s sock.settimeout(timeout) 1747s if source_address: 1747s sock.bind(source_address) 1747s > sock.connect(sa) 1747s E ConnectionRefusedError: [Errno 111] Connection refused 1747s 1747s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1747s 1747s During handling of the above exception, another exception occurred: 1747s 1747s self = 1747s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1747s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def mysql_pymysql_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s pymysql = td.versioned_importorskip("pymysql") 1747s engine = sqlalchemy.create_engine( 1747s "mysql+pymysql://root@localhost:3306/pandas", 1747s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1747s self.connect() 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1747s try: 1747s sock = socket.create_connection( 1747s (self.host, self.port), self.connect_timeout, **kwargs 1747s ) 1747s break 1747s except OSError as e: 1747s if e.errno == errno.EINTR: 1747s continue 1747s raise 1747s self.host_info = "socket %s:%d" % (self.host, self.port) 1747s if DEBUG: 1747s print("connected using socket") 1747s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1747s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1747s sock.settimeout(None) 1747s 1747s self._sock = sock 1747s self._rfile = sock.makefile("rb") 1747s self._next_seq_id = 0 1747s 1747s self._get_server_information() 1747s self._request_authentication() 1747s 1747s # Send "SET NAMES" query on init for: 1747s # - Ensure charaset (and collation) is set to the server. 1747s # - collation_id in handshake packet may be ignored. 1747s # - If collation is not specified, we don't know what is server's 1747s # default collation for the charset. For example, default collation 1747s # of utf8mb4 is: 1747s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1747s # - MySQL 8.0: utf8mb4_0900_ai_ci 1747s # 1747s # Reference: 1747s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1747s # - https://github.com/wagtail/wagtail/issues/9477 1747s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1747s self.set_character_set(self.charset, self.collation) 1747s 1747s if self.sql_mode is not None: 1747s c = self.cursor() 1747s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1747s c.close() 1747s 1747s if self.init_command is not None: 1747s c = self.cursor() 1747s c.execute(self.init_command) 1747s c.close() 1747s 1747s if self.autocommit_mode is not None: 1747s self.autocommit(self.autocommit_mode) 1747s except BaseException as e: 1747s self._rfile = None 1747s if sock is not None: 1747s try: 1747s sock.close() 1747s except: # noqa 1747s pass 1747s 1747s if isinstance(e, (OSError, IOError)): 1747s exc = err.OperationalError( 1747s CR.CR_CONN_HOST_ERROR, 1747s f"Can't connect to MySQL server on {self.host!r} ({e})", 1747s ) 1747s # Keep original exception and traceback to investigate error. 1747s exc.original_exception = e 1747s exc.traceback = traceback.format_exc() 1747s if DEBUG: 1747s print(exc.traceback) 1747s > raise exc 1747s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1747s _ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_engine] __ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s __ ERROR at teardown of test_api_integer_col_names[postgresql_psycopg2_conn] ___ 1747s self = 1747s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1747s connection = None, _has_events = None, _allow_revalidate = True 1747s _allow_autobegin = True 1747s 1747s def __init__( 1747s self, 1747s engine: Engine, 1747s connection: Optional[PoolProxiedConnection] = None, 1747s _has_events: Optional[bool] = None, 1747s _allow_revalidate: bool = True, 1747s _allow_autobegin: bool = True, 1747s ): 1747s """Construct a new Connection.""" 1747s self.engine = engine 1747s self.dialect = dialect = engine.dialect 1747s 1747s if connection is None: 1747s try: 1747s > self._dbapi_connection = engine.raw_connection() 1747s 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s 1747s The above exception was the direct cause of the following exception: 1747s 1747s @pytest.fixture 1747s def postgresql_psycopg2_engine(): 1747s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1747s td.versioned_importorskip("psycopg2") 1747s engine = sqlalchemy.create_engine( 1747s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1747s poolclass=sqlalchemy.pool.NullPool, 1747s ) 1747s yield engine 1747s > for view in get_all_views(engine): 1747s 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1747s return inspect(conn).get_view_names() 1747s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1747s ret = reg(subject) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1747s return Inspector._construct(Inspector._init_engine, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1747s init(self, bind) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1747s engine.connect().close() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1747s return self._connection_cls(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1747s Connection._handle_dbapi_exception_noconnection( 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1747s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1747s self._dbapi_connection = engine.raw_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1747s return self.pool.connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1747s return _ConnectionFairy._checkout(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1747s fairy = _ConnectionRecord.checkout(pool) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1747s rec = pool._do_get() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1747s return self._create_connection() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1747s return _ConnectionRecord(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1747s self.__connect() 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1747s with util.safe_reraise(): 1747s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1747s raise exc_value.with_traceback(exc_tb) 1747s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1747s self.dbapi_connection = connection = pool._invoke_creator(self) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1747s return dialect.connect(*cargs, **cparams) 1747s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1747s return self.loaded_dbapi.connect(*cargs, **cparams) 1747s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1747s 1747s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1747s connection_factory = None, cursor_factory = None 1747s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1747s kwasync = {} 1747s 1747s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1747s """ 1747s Create a new database connection. 1747s 1747s The connection parameters can be specified as a string: 1747s 1747s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1747s 1747s or using a set of keyword arguments: 1747s 1747s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1747s 1747s Or as a mix of both. The basic connection parameters are: 1747s 1747s - *dbname*: the database name 1747s - *database*: the database name (only as keyword argument) 1747s - *user*: user name used to authenticate 1747s - *password*: password used to authenticate 1747s - *host*: database host address (defaults to UNIX socket if not provided) 1747s - *port*: connection port number (defaults to 5432 if not provided) 1747s 1747s Using the *connection_factory* parameter a different class or connections 1747s factory can be specified. It should be a callable object taking a dsn 1747s argument. 1747s 1747s Using the *cursor_factory* parameter, a new default cursor factory will be 1747s used by cursor(). 1747s 1747s Using *async*=True an asynchronous connection will be created. *async_* is 1747s a valid alias (for Python versions where ``async`` is a keyword). 1747s 1747s Any other keyword parameter will be passed to the underlying client 1747s library: the list of supported parameters depends on the library version. 1747s 1747s """ 1747s kwasync = {} 1747s if 'async' in kwargs: 1747s kwasync['async'] = kwargs.pop('async') 1747s if 'async_' in kwargs: 1747s kwasync['async_'] = kwargs.pop('async_') 1747s 1747s dsn = _ext.make_dsn(dsn, **kwargs) 1747s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1747s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1747s E Is the server running on that host and accepting TCP/IP connections? 1747s E 1747s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1747s 1747s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1747s ________ ERROR at teardown of test_api_get_schema[mysql_pymysql_engine] ________ 1747s self = , sock = None 1747s 1747s def connect(self, sock=None): 1747s self._closed = False 1747s try: 1747s if sock is None: 1747s if self.unix_socket: 1747s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1747s sock.settimeout(self.connect_timeout) 1747s sock.connect(self.unix_socket) 1747s self.host_info = "Localhost via UNIX socket" 1747s self._secure = True 1747s if DEBUG: 1747s print("connected using unix_socket") 1747s else: 1747s kwargs = {} 1747s if self.bind_address is not None: 1747s kwargs["source_address"] = (self.bind_address, 0) 1747s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _________ ERROR at teardown of test_api_get_schema[mysql_pymysql_conn] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_engine] _____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_api_get_schema[postgresql_psycopg2_conn] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_engine] __ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___ ERROR at teardown of test_api_get_schema_with_schema[mysql_pymysql_conn] ___ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_api_get_schema_with_schema[postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_engine] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_api_get_schema_dtypes[mysql_pymysql_conn] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_engine] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_api_get_schema_dtypes[postgresql_psycopg2_conn] ___ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _____ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_engine] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______ ERROR at teardown of test_api_get_schema_keys[mysql_pymysql_conn] _______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_engine] ___ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___ ERROR at teardown of test_api_get_schema_keys[postgresql_psycopg2_conn] ____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_engine] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______ ERROR at teardown of test_api_chunksize_read[mysql_pymysql_conn] _______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_engine] ___ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_api_chunksize_read[postgresql_psycopg2_conn] ____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______ ERROR at teardown of test_api_categorical[mysql_pymysql_engine] ________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ________ ERROR at teardown of test_api_categorical[mysql_pymysql_conn] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_engine] _____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _____ ERROR at teardown of test_api_categorical[postgresql_psycopg2_conn] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_engine] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____ ERROR at teardown of test_api_unicode_column_name[mysql_pymysql_conn] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_api_unicode_column_name[postgresql_psycopg2_conn] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_engine] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_api_escaped_table_name[mysql_pymysql_conn] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_api_escaped_table_name[postgresql_psycopg2_conn] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_api_read_sql_duplicate_columns[mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_read_table_columns[mysql_pymysql_engine] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______ ERROR at teardown of test_read_table_columns[mysql_pymysql_conn] _______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_engine] ___ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_read_table_columns[postgresql_psycopg2_conn] ____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _____ ERROR at teardown of test_read_table_index_col[mysql_pymysql_engine] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______ ERROR at teardown of test_read_table_index_col[mysql_pymysql_conn] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_engine] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___ ERROR at teardown of test_read_table_index_col[postgresql_psycopg2_conn] ___ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_engine_iris] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_read_sql_delegate[mysql_pymysql_conn_iris] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_engine_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_read_sql_delegate[postgresql_psycopg2_conn_iris] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_warning_case_insensitive_table_name[mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_engine] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____ ERROR at teardown of test_sqlalchemy_type_mapping[mysql_pymysql_conn] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _____ ERROR at teardown of test_database_uri_string[mysql_pymysql_engine] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______ ERROR at teardown of test_database_uri_string[mysql_pymysql_conn] _______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_engine] ___ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___ ERROR at teardown of test_database_uri_string[postgresql_psycopg2_conn] ____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_engine_iris] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_query_by_text_obj[mysql_pymysql_conn_iris] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_engine_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_query_by_text_obj[postgresql_psycopg2_conn_iris] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_engine_iris] ___ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____ ERROR at teardown of test_query_by_select_obj[mysql_pymysql_conn_iris] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_engine_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_query_by_select_obj[postgresql_psycopg2_conn_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_engine] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_column_with_percentage[mysql_pymysql_conn] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_column_with_percentage[postgresql_psycopg2_conn] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _________ ERROR at teardown of test_create_table[mysql_pymysql_engine] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __________ ERROR at teardown of test_create_table[mysql_pymysql_conn] __________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______ ERROR at teardown of test_create_table[postgresql_psycopg2_engine] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______ ERROR at teardown of test_create_table[postgresql_psycopg2_conn] _______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __________ ERROR at teardown of test_drop_table[mysql_pymysql_engine] __________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___________ ERROR at teardown of test_drop_table[mysql_pymysql_conn] ___________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______ ERROR at teardown of test_drop_table[postgresql_psycopg2_engine] _______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ________ ERROR at teardown of test_drop_table[postgresql_psycopg2_conn] ________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __________ ERROR at teardown of test_roundtrip[mysql_pymysql_engine] ___________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___________ ERROR at teardown of test_roundtrip[mysql_pymysql_conn] ____________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______ ERROR at teardown of test_roundtrip[postgresql_psycopg2_engine] ________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ________ ERROR at teardown of test_roundtrip[postgresql_psycopg2_conn] _________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______ ERROR at teardown of test_execute_sql[mysql_pymysql_engine_iris] _______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ________ ERROR at teardown of test_execute_sql[mysql_pymysql_conn_iris] ________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_engine_iris] ____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _____ ERROR at teardown of test_execute_sql[postgresql_psycopg2_conn_iris] _____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_engine_iris] __ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___ ERROR at teardown of test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ___ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_engine_iris] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_table_absent_raises[mysql_pymysql_conn_iris] __ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_engine_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____________ ERROR at teardown of test_bigint[mysql_pymysql_engine] ____________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____________ ERROR at teardown of test_bigint[mysql_pymysql_conn] _____________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _________ ERROR at teardown of test_bigint[postgresql_psycopg2_engine] _________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __________ ERROR at teardown of test_bigint[postgresql_psycopg2_conn] __________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___ ERROR at teardown of test_default_date_load[mysql_pymysql_engine_types] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____ ERROR at teardown of test_default_date_load[mysql_pymysql_conn_types] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_engine_types] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_default_date_load[postgresql_psycopg2_conn_types] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_table[postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_engine] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_out_of_bounds_datetime[mysql_pymysql_conn] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_out_of_bounds_datetime[postgresql_psycopg2_conn] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] __ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_date_parsing[mysql_pymysql_engine_types] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______ ERROR at teardown of test_date_parsing[mysql_pymysql_conn_types] _______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___ ERROR at teardown of test_date_parsing[postgresql_psycopg2_engine_types] ___ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_date_parsing[postgresql_psycopg2_conn_types] ____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___________ ERROR at teardown of test_datetime[mysql_pymysql_engine] ___________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____________ ERROR at teardown of test_datetime[mysql_pymysql_conn] ____________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ________ ERROR at teardown of test_datetime[postgresql_psycopg2_engine] ________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _________ ERROR at teardown of test_datetime[postgresql_psycopg2_conn] _________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_engine] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __________ ERROR at teardown of test_datetime_NaT[mysql_pymysql_conn] __________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_engine] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______ ERROR at teardown of test_datetime_NaT[postgresql_psycopg2_conn] _______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ________ ERROR at teardown of test_datetime_date[mysql_pymysql_engine] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _________ ERROR at teardown of test_datetime_date[mysql_pymysql_conn] __________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_datetime_date[postgresql_psycopg2_engine] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_datetime_date[postgresql_psycopg2_conn] _______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ________ ERROR at teardown of test_datetime_time[mysql_pymysql_engine] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _________ ERROR at teardown of test_datetime_time[mysql_pymysql_conn] __________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_datetime_time[postgresql_psycopg2_engine] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_datetime_time[postgresql_psycopg2_conn] _______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_engine] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______ ERROR at teardown of test_mixed_dtype_insert[mysql_pymysql_conn] _______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_engine] ___ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_mixed_dtype_insert[postgresql_psycopg2_conn] ____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _________ ERROR at teardown of test_nan_numeric[mysql_pymysql_engine] __________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __________ ERROR at teardown of test_nan_numeric[mysql_pymysql_conn] ___________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_engine] _______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______ ERROR at teardown of test_nan_numeric[postgresql_psycopg2_conn] ________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_engine] ________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _________ ERROR at teardown of test_nan_fullcolumn[mysql_pymysql_conn] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_engine] _____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_nan_fullcolumn[postgresql_psycopg2_conn] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __________ ERROR at teardown of test_nan_string[mysql_pymysql_engine] __________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___________ ERROR at teardown of test_nan_string[mysql_pymysql_conn] ___________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______ ERROR at teardown of test_nan_string[postgresql_psycopg2_engine] _______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ________ ERROR at teardown of test_nan_string[postgresql_psycopg2_conn] ________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_engine] _______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______ ERROR at teardown of test_to_sql_save_index[mysql_pymysql_conn] ________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_engine] ____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_to_sql_save_index[postgresql_psycopg2_conn] _____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _________ ERROR at teardown of test_transactions[mysql_pymysql_engine] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __________ ERROR at teardown of test_transactions[mysql_pymysql_conn] __________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______ ERROR at teardown of test_transactions[postgresql_psycopg2_engine] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______ ERROR at teardown of test_transactions[postgresql_psycopg2_conn] _______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _____ ERROR at teardown of test_transaction_rollback[mysql_pymysql_engine] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______ ERROR at teardown of test_transaction_rollback[mysql_pymysql_conn] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_engine] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___ ERROR at teardown of test_transaction_rollback[postgresql_psycopg2_conn] ___ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_engine] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____ ERROR at teardown of test_get_schema_create_table[mysql_pymysql_conn] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_get_schema_create_table[postgresql_psycopg2_conn] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____________ ERROR at teardown of test_dtype[mysql_pymysql_engine] _____________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____________ ERROR at teardown of test_dtype[mysql_pymysql_conn] ______________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _________ ERROR at teardown of test_dtype[postgresql_psycopg2_engine] __________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __________ ERROR at teardown of test_dtype[postgresql_psycopg2_conn] ___________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _________ ERROR at teardown of test_notna_dtype[mysql_pymysql_engine] __________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __________ ERROR at teardown of test_notna_dtype[mysql_pymysql_conn] ___________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_engine] _______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______ ERROR at teardown of test_notna_dtype[postgresql_psycopg2_conn] ________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______ ERROR at teardown of test_double_precision[mysql_pymysql_engine] _______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ________ ERROR at teardown of test_double_precision[mysql_pymysql_conn] ________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____ ERROR at teardown of test_double_precision[postgresql_psycopg2_engine] ____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _____ ERROR at teardown of test_double_precision[postgresql_psycopg2_conn] _____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_engine] ___ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___ ERROR at teardown of test_connectable_issue_example[mysql_pymysql_conn] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_connectable_issue_example[postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______ ERROR at teardown of test_temporary_table[mysql_pymysql_engine] ________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ________ ERROR at teardown of test_temporary_table[mysql_pymysql_conn] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_engine] _____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _____ ERROR at teardown of test_temporary_table[postgresql_psycopg2_conn] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ________ ERROR at teardown of test_invalid_engine[mysql_pymysql_engine] ________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _________ ERROR at teardown of test_invalid_engine[mysql_pymysql_conn] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_engine] _____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_invalid_engine[postgresql_psycopg2_conn] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_engine] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_to_sql_with_sql_engine[mysql_pymysql_conn] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_to_sql_with_sql_engine[postgresql_psycopg2_conn] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_engine] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______ ERROR at teardown of test_options_sqlalchemy[mysql_pymysql_conn] _______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_engine] ___ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_options_sqlalchemy[postgresql_psycopg2_conn] ____ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _________ ERROR at teardown of test_options_auto[mysql_pymysql_engine] _________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __________ ERROR at teardown of test_options_auto[mysql_pymysql_conn] __________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______ ERROR at teardown of test_options_auto[postgresql_psycopg2_engine] ______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______ ERROR at teardown of test_options_auto[postgresql_psycopg2_conn] _______ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_engine] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ ERROR at teardown of test_chunksize_empty_dtypes[mysql_pymysql_conn] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ ERROR at teardown of test_chunksize_empty_dtypes[postgresql_psycopg2_conn] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def mysql_pymysql_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s pymysql = td.versioned_importorskip("pymysql") 1748s engine = sqlalchemy.create_engine( 1748s "mysql+pymysql://root@localhost:3306/pandas", 1748s connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS}, 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:612: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ ERROR at teardown of test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______________ ERROR at teardown of test_psycopg2_schema_support _______________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______________ ERROR at teardown of test_self_join_date_columns _______________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s @pytest.fixture 1748s def postgresql_psycopg2_engine(): 1748s sqlalchemy = td.versioned_importorskip("sqlalchemy") 1748s td.versioned_importorskip("psycopg2") 1748s engine = sqlalchemy.create_engine( 1748s "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas", 1748s poolclass=sqlalchemy.pool.NullPool, 1748s ) 1748s yield engine 1748s > for view in get_all_views(engine): 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:659: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:533: in get_all_views 1748s return inspect(conn).get_view_names() 1748s /usr/lib/python3/dist-packages/sqlalchemy/inspection.py:140: in inspect 1748s ret = reg(subject) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:313: in _engine_insp 1748s return Inspector._construct(Inspector._init_engine, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:246: in _construct 1748s init(self, bind) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/reflection.py:257: in _init_engine 1748s engine.connect().close() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s =================================== FAILURES =================================== 1748s _________________ test_dataframe_to_sql[mysql_pymysql_engine] __________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_dataframe_to_sql(conn, test_frame1, request): 1748s # GH 51086 if conn is sqlite_engine 1748s conn = request.getfixturevalue(conn) 1748s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1748s return func(*args, **kwargs) 1748s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1748s return sql.to_sql( 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1748s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __________________ test_dataframe_to_sql[mysql_pymysql_conn] ___________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn' 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_dataframe_to_sql(conn, test_frame1, request): 1748s # GH 51086 if conn is sqlite_engine 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1748s with mysql_pymysql_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______________ test_dataframe_to_sql[postgresql_psycopg2_engine] _______________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_dataframe_to_sql(conn, test_frame1, request): 1748s # GH 51086 if conn is sqlite_engine 1748s conn = request.getfixturevalue(conn) 1748s > test_frame1.to_sql(name="test", con=conn, if_exists="append", index=False) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:983: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1748s return func(*args, **kwargs) 1748s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1748s return sql.to_sql( 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1748s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______________ test_dataframe_to_sql[postgresql_psycopg2_conn] ________________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_conn' 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_dataframe_to_sql(conn, test_frame1, request): 1748s # GH 51086 if conn is sqlite_engine 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:982: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1748s with postgresql_psycopg2_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______________ test_dataframe_to_sql_empty[mysql_pymysql_engine] _______________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1748s if conn == "postgresql_adbc_conn": 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="postgres ADBC driver cannot insert index with null type", 1748s strict=True, 1748s ) 1748s ) 1748s # GH 51086 if conn is sqlite_engine 1748s conn = request.getfixturevalue(conn) 1748s empty_df = test_frame1.iloc[:0] 1748s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1748s return func(*args, **kwargs) 1748s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1748s return sql.to_sql( 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1748s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______________ test_dataframe_to_sql_empty[mysql_pymysql_conn] ________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn' 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1748s if conn == "postgresql_adbc_conn": 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="postgres ADBC driver cannot insert index with null type", 1748s strict=True, 1748s ) 1748s ) 1748s # GH 51086 if conn is sqlite_engine 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1748s with mysql_pymysql_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___________ test_dataframe_to_sql_empty[postgresql_psycopg2_engine] ____________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1748s if conn == "postgresql_adbc_conn": 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="postgres ADBC driver cannot insert index with null type", 1748s strict=True, 1748s ) 1748s ) 1748s # GH 51086 if conn is sqlite_engine 1748s conn = request.getfixturevalue(conn) 1748s empty_df = test_frame1.iloc[:0] 1748s > empty_df.to_sql(name="test", con=conn, if_exists="append", index=False) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:998: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1748s return func(*args, **kwargs) 1748s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1748s return sql.to_sql( 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1748s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____________ test_dataframe_to_sql_empty[postgresql_psycopg2_conn] _____________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_conn' 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_dataframe_to_sql_empty(conn, test_frame1, request): 1748s if conn == "postgresql_adbc_conn": 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="postgres ADBC driver cannot insert index with null type", 1748s strict=True, 1748s ) 1748s ) 1748s # GH 51086 if conn is sqlite_engine 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:996: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1748s with postgresql_psycopg2_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____________________ test_to_sql[None-mysql_pymysql_engine] ____________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = None 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("method", [None, "multi"]) 1748s def test_to_sql(conn, method, test_frame1, request): 1748s if method == "multi" and "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'method' not implemented for ADBC drivers", strict=True 1748s ) 1748s ) 1748s 1748s conn = request.getfixturevalue(conn) 1748s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____________________ test_to_sql[None-mysql_pymysql_conn] _____________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn', method = None 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("method", [None, "multi"]) 1748s def test_to_sql(conn, method, test_frame1, request): 1748s if method == "multi" and "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'method' not implemented for ADBC drivers", strict=True 1748s ) 1748s ) 1748s 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1748s with mysql_pymysql_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _________________ test_to_sql[None-postgresql_psycopg2_engine] _________________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s method = None 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("method", [None, "multi"]) 1748s def test_to_sql(conn, method, test_frame1, request): 1748s if method == "multi" and "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'method' not implemented for ADBC drivers", strict=True 1748s ) 1748s ) 1748s 1748s conn = request.getfixturevalue(conn) 1748s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __________________ test_to_sql[None-postgresql_psycopg2_conn] __________________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_conn', method = None 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("method", [None, "multi"]) 1748s def test_to_sql(conn, method, test_frame1, request): 1748s if method == "multi" and "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'method' not implemented for ADBC drivers", strict=True 1748s ) 1748s ) 1748s 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1748s with postgresql_psycopg2_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ___________________ test_to_sql[multi-mysql_pymysql_engine] ____________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), method = 'multi' 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("method", [None, "multi"]) 1748s def test_to_sql(conn, method, test_frame1, request): 1748s if method == "multi" and "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'method' not implemented for ADBC drivers", strict=True 1748s ) 1748s ) 1748s 1748s conn = request.getfixturevalue(conn) 1748s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____________________ test_to_sql[multi-mysql_pymysql_conn] _____________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn', method = 'multi' 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("method", [None, "multi"]) 1748s def test_to_sql(conn, method, test_frame1, request): 1748s if method == "multi" and "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'method' not implemented for ADBC drivers", strict=True 1748s ) 1748s ) 1748s 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1748s with mysql_pymysql_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ________________ test_to_sql[multi-postgresql_psycopg2_engine] _________________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s method = 'multi' 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("method", [None, "multi"]) 1748s def test_to_sql(conn, method, test_frame1, request): 1748s if method == "multi" and "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'method' not implemented for ADBC drivers", strict=True 1748s ) 1748s ) 1748s 1748s conn = request.getfixturevalue(conn) 1748s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1061: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _________________ test_to_sql[multi-postgresql_psycopg2_conn] __________________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_conn', method = 'multi' 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("method", [None, "multi"]) 1748s def test_to_sql(conn, method, test_frame1, request): 1748s if method == "multi" and "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'method' not implemented for ADBC drivers", strict=True 1748s ) 1748s ) 1748s 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1060: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1748s with postgresql_psycopg2_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ______________ test_to_sql_exist[replace-1-mysql_pymysql_engine] _______________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'replace' 1748s num_row_coef = 1 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1748s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1748s conn = request.getfixturevalue(conn) 1748s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______________ test_to_sql_exist[replace-1-mysql_pymysql_conn] ________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn', mode = 'replace', num_row_coef = 1 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1748s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1748s with mysql_pymysql_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___________ test_to_sql_exist[replace-1-postgresql_psycopg2_engine] ____________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s mode = 'replace', num_row_coef = 1 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1748s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1748s conn = request.getfixturevalue(conn) 1748s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____________ test_to_sql_exist[replace-1-postgresql_psycopg2_conn] _____________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_conn', mode = 'replace', num_row_coef = 1 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1748s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1748s with postgresql_psycopg2_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______________ test_to_sql_exist[append-2-mysql_pymysql_engine] _______________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(mysql+pymysql://root@localhost:3306/pandas), mode = 'append' 1748s num_row_coef = 2 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1748s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1748s conn = request.getfixturevalue(conn) 1748s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ________________ test_to_sql_exist[append-2-mysql_pymysql_conn] ________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn', mode = 'append', num_row_coef = 2 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1748s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1748s with mysql_pymysql_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____________ test_to_sql_exist[append-2-postgresql_psycopg2_engine] ____________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s mode = 'append', num_row_coef = 2 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1748s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1748s conn = request.getfixturevalue(conn) 1748s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1071: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _____________ test_to_sql_exist[append-2-postgresql_psycopg2_conn] _____________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_conn', mode = 'append', num_row_coef = 2 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s @pytest.mark.parametrize("mode, num_row_coef", [("replace", 1), ("append", 2)]) 1748s def test_to_sql_exist(conn, mode, num_row_coef, test_frame1, request): 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1070: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1748s with postgresql_psycopg2_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _________________ test_to_sql_exist_fail[mysql_pymysql_engine] _________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_to_sql_exist_fail(conn, test_frame1, request): 1748s conn = request.getfixturevalue(conn) 1748s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s __________________ test_to_sql_exist_fail[mysql_pymysql_conn] __________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn' 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_to_sql_exist_fail(conn, test_frame1, request): 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1748s with mysql_pymysql_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ______________ test_to_sql_exist_fail[postgresql_psycopg2_engine] ______________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_to_sql_exist_fail(conn, test_frame1, request): 1748s conn = request.getfixturevalue(conn) 1748s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1081: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1748s return SQLDatabase(con, schema, need_transaction) 1748s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1748s con = self.exit_stack.enter_context(con.connect()) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______________ test_to_sql_exist_fail[postgresql_psycopg2_conn] _______________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_conn' 1748s test_frame1 = index A B C D 1748s 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 1748s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable) 1748s def test_to_sql_exist_fail(conn, test_frame1, request): 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1080: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1748s with postgresql_psycopg2_engine.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _______________ test_read_iris_query[mysql_pymysql_engine_iris] ________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_engine_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable_iris) 1748s def test_read_iris_query(conn, request): 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1748s create_and_load_iris(mysql_pymysql_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ________________ test_read_iris_query[mysql_pymysql_conn_iris] _________________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable_iris) 1748s def test_read_iris_query(conn, request): 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1748s fixturedef = request._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1748s create_and_load_iris(mysql_pymysql_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ____________ test_read_iris_query[postgresql_psycopg2_engine_iris] _____________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_engine_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable_iris) 1748s def test_read_iris_query(conn, request): 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1748s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _____________ test_read_iris_query[postgresql_psycopg2_conn_iris] ______________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_conn_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable_iris) 1748s def test_read_iris_query(conn, request): 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1092: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1748s fixturedef = request._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1748s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __________ test_read_iris_query_chunksize[mysql_pymysql_engine_iris] ___________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_engine_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable_iris) 1748s def test_read_iris_query_chunksize(conn, request): 1748s if "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'chunksize' not implemented for ADBC drivers", 1748s strict=True, 1748s ) 1748s ) 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1748s create_and_load_iris(mysql_pymysql_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___________ test_read_iris_query_chunksize[mysql_pymysql_conn_iris] ____________ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable_iris) 1748s def test_read_iris_query_chunksize(conn, request): 1748s if "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'chunksize' not implemented for ADBC drivers", 1748s strict=True, 1748s ) 1748s ) 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1748s fixturedef = request._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1748s create_and_load_iris(mysql_pymysql_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _______ test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] ________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_engine_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable_iris) 1748s def test_read_iris_query_chunksize(conn, request): 1748s if "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'chunksize' not implemented for ADBC drivers", 1748s strict=True, 1748s ) 1748s ) 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1748s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ________ test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] _________ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_conn_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", all_connectable_iris) 1748s def test_read_iris_query_chunksize(conn, request): 1748s if "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'chunksize' not implemented for ADBC drivers", 1748s strict=True, 1748s ) 1748s ) 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1111: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1748s fixturedef = request._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1748s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s __ test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] ___ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_engine_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1748s def test_read_iris_query_expression_with_parameter(conn, request): 1748s if "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'chunksize' not implemented for ADBC drivers", 1748s strict=True, 1748s ) 1748s ) 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1748s create_and_load_iris(mysql_pymysql_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s ___ test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] ____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1748s def test_read_iris_query_expression_with_parameter(conn, request): 1748s if "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'chunksize' not implemented for ADBC drivers", 1748s strict=True, 1748s ) 1748s ) 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1748s fixturedef = request._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1748s create_and_load_iris(mysql_pymysql_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_engine_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1748s def test_read_iris_query_expression_with_parameter(conn, request): 1748s if "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'chunksize' not implemented for ADBC drivers", 1748s strict=True, 1748s ) 1748s ) 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1748s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s _ test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] _ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'postgresql_psycopg2_conn_iris' 1748s request = > 1748s 1748s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1748s def test_read_iris_query_expression_with_parameter(conn, request): 1748s if "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'chunksize' not implemented for ADBC drivers", 1748s strict=True, 1748s ) 1748s ) 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1130: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1748s fixturedef = request._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1748s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1748s used by cursor(). 1748s 1748s Using *async*=True an asynchronous connection will be created. *async_* is 1748s a valid alias (for Python versions where ``async`` is a keyword). 1748s 1748s Any other keyword parameter will be passed to the underlying client 1748s library: the list of supported parameters depends on the library version. 1748s 1748s """ 1748s kwasync = {} 1748s if 'async' in kwargs: 1748s kwasync['async'] = kwargs.pop('async') 1748s if 'async_' in kwargs: 1748s kwasync['async_'] = kwargs.pop('async_') 1748s 1748s dsn = _ext.make_dsn(dsn, **kwargs) 1748s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1748s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1748s E Is the server running on that host and accepting TCP/IP connections? 1748s E 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1748s ____ test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] _____ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_engine_iris' 1748s request = > 1748s 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=?'}} 1748s 1748s @pytest.mark.parametrize("conn", all_connectable_iris) 1748s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1748s if "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'chunksize' not implemented for ADBC drivers", 1748s strict=True, 1748s ) 1748s ) 1748s 1748s for db, query in sql_strings["read_parameters"].items(): 1748s if db in conn: 1748s break 1748s else: 1748s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1748s create_and_load_iris(mysql_pymysql_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _____ test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] ______ 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s > sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3.13/socket.py:864: in create_connection 1748s raise exceptions[0] 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s address = ('localhost', 3306), timeout = 10, source_address = None 1748s 1748s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1748s source_address=None, *, all_errors=False): 1748s """Connect to *address* and return the socket object. 1748s 1748s Convenience function. Connect to *address* (a 2-tuple ``(host, 1748s port)``) and return the socket object. Passing the optional 1748s *timeout* parameter will set the timeout on the socket instance 1748s before attempting to connect. If no *timeout* is supplied, the 1748s global default timeout setting returned by :func:`getdefaulttimeout` 1748s is used. If *source_address* is set it must be a tuple of (host, port) 1748s for the socket to bind as a source address before making the connection. 1748s A host of '' or port 0 tells the OS to use the default. When a connection 1748s cannot be created, raises the last error if *all_errors* is False, 1748s and an ExceptionGroup of all errors if *all_errors* is True. 1748s """ 1748s 1748s host, port = address 1748s exceptions = [] 1748s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1748s af, socktype, proto, canonname, sa = res 1748s sock = None 1748s try: 1748s sock = socket(af, socktype, proto) 1748s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1748s sock.settimeout(timeout) 1748s if source_address: 1748s sock.bind(source_address) 1748s > sock.connect(sa) 1748s E ConnectionRefusedError: [Errno 111] Connection refused 1748s 1748s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1748s 1748s During handling of the above exception, another exception occurred: 1748s 1748s self = 1748s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1748s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s 1748s The above exception was the direct cause of the following exception: 1748s 1748s conn = 'mysql_pymysql_conn_iris' 1748s request = > 1748s 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=?'}} 1748s 1748s @pytest.mark.parametrize("conn", all_connectable_iris) 1748s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1748s if "adbc" in conn: 1748s request.node.add_marker( 1748s pytest.mark.xfail( 1748s reason="'chunksize' not implemented for ADBC drivers", 1748s strict=True, 1748s ) 1748s ) 1748s 1748s for db, query in sql_strings["read_parameters"].items(): 1748s if db in conn: 1748s break 1748s else: 1748s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1748s > conn = request.getfixturevalue(conn) 1748s 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1748s fixturedef = self._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1748s fixturedef = request._get_active_fixturedef(argname) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1748s fixturedef.execute(request=subrequest) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1748s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1748s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1748s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1748s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1748s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1748s return (yield) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1748s result = call_fixture_func(fixturefunc, request, kwargs) 1748s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1748s fixture_result = next(generator) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1748s create_and_load_iris(mysql_pymysql_engine, iris_path) 1748s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1748s with conn.begin() as con: 1748s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1748s return next(self.gen) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1748s with self.connect() as conn: 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1748s return self._connection_cls(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1748s Connection._handle_dbapi_exception_noconnection( 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1748s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1748s self._dbapi_connection = engine.raw_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1748s self.connect() 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s self = , sock = None 1748s 1748s def connect(self, sock=None): 1748s self._closed = False 1748s try: 1748s if sock is None: 1748s if self.unix_socket: 1748s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1748s sock.settimeout(self.connect_timeout) 1748s sock.connect(self.unix_socket) 1748s self.host_info = "Localhost via UNIX socket" 1748s self._secure = True 1748s if DEBUG: 1748s print("connected using unix_socket") 1748s else: 1748s kwargs = {} 1748s if self.bind_address is not None: 1748s kwargs["source_address"] = (self.bind_address, 0) 1748s while True: 1748s try: 1748s sock = socket.create_connection( 1748s (self.host, self.port), self.connect_timeout, **kwargs 1748s ) 1748s break 1748s except OSError as e: 1748s if e.errno == errno.EINTR: 1748s continue 1748s raise 1748s self.host_info = "socket %s:%d" % (self.host, self.port) 1748s if DEBUG: 1748s print("connected using socket") 1748s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1748s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1748s sock.settimeout(None) 1748s 1748s self._sock = sock 1748s self._rfile = sock.makefile("rb") 1748s self._next_seq_id = 0 1748s 1748s self._get_server_information() 1748s self._request_authentication() 1748s 1748s # Send "SET NAMES" query on init for: 1748s # - Ensure charaset (and collation) is set to the server. 1748s # - collation_id in handshake packet may be ignored. 1748s # - If collation is not specified, we don't know what is server's 1748s # default collation for the charset. For example, default collation 1748s # of utf8mb4 is: 1748s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1748s # - MySQL 8.0: utf8mb4_0900_ai_ci 1748s # 1748s # Reference: 1748s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1748s # - https://github.com/wagtail/wagtail/issues/9477 1748s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1748s self.set_character_set(self.charset, self.collation) 1748s 1748s if self.sql_mode is not None: 1748s c = self.cursor() 1748s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1748s c.close() 1748s 1748s if self.init_command is not None: 1748s c = self.cursor() 1748s c.execute(self.init_command) 1748s c.close() 1748s 1748s if self.autocommit_mode is not None: 1748s self.autocommit(self.autocommit_mode) 1748s except BaseException as e: 1748s self._rfile = None 1748s if sock is not None: 1748s try: 1748s sock.close() 1748s except: # noqa 1748s pass 1748s 1748s if isinstance(e, (OSError, IOError)): 1748s exc = err.OperationalError( 1748s CR.CR_CONN_HOST_ERROR, 1748s f"Can't connect to MySQL server on {self.host!r} ({e})", 1748s ) 1748s # Keep original exception and traceback to investigate error. 1748s exc.original_exception = e 1748s exc.traceback = traceback.format_exc() 1748s if DEBUG: 1748s print(exc.traceback) 1748s > raise exc 1748s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1748s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1748s 1748s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1748s _ test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] __ 1748s self = 1748s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1748s connection = None, _has_events = None, _allow_revalidate = True 1748s _allow_autobegin = True 1748s 1748s def __init__( 1748s self, 1748s engine: Engine, 1748s connection: Optional[PoolProxiedConnection] = None, 1748s _has_events: Optional[bool] = None, 1748s _allow_revalidate: bool = True, 1748s _allow_autobegin: bool = True, 1748s ): 1748s """Construct a new Connection.""" 1748s self.engine = engine 1748s self.dialect = dialect = engine.dialect 1748s 1748s if connection is None: 1748s try: 1748s > self._dbapi_connection = engine.raw_connection() 1748s 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1748s return self.pool.connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1748s return _ConnectionFairy._checkout(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1748s fairy = _ConnectionRecord.checkout(pool) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1748s rec = pool._do_get() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1748s return self._create_connection() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1748s return _ConnectionRecord(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1748s self.__connect() 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1748s with util.safe_reraise(): 1748s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1748s raise exc_value.with_traceback(exc_tb) 1748s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1748s self.dbapi_connection = connection = pool._invoke_creator(self) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1748s return dialect.connect(*cargs, **cparams) 1748s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1748s return self.loaded_dbapi.connect(*cargs, **cparams) 1748s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1748s 1748s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1748s connection_factory = None, cursor_factory = None 1748s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1748s kwasync = {} 1748s 1748s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1748s """ 1748s Create a new database connection. 1748s 1748s The connection parameters can be specified as a string: 1748s 1748s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1748s 1748s or using a set of keyword arguments: 1748s 1748s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1748s 1748s Or as a mix of both. The basic connection parameters are: 1748s 1748s - *dbname*: the database name 1748s - *database*: the database name (only as keyword argument) 1748s - *user*: user name used to authenticate 1748s - *password*: password used to authenticate 1748s - *host*: database host address (defaults to UNIX socket if not provided) 1748s - *port*: connection port number (defaults to 5432 if not provided) 1748s 1748s Using the *connection_factory* parameter a different class or connections 1748s factory can be specified. It should be a callable object taking a dsn 1748s argument. 1748s 1748s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 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=?'}} 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'chunksize' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s 1749s for db, query in sql_strings["read_parameters"].items(): 1749s if db in conn: 1749s break 1749s else: 1749s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __ test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 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=?'}} 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_iris_query_string_with_parameter(conn, request, sql_strings): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'chunksize' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s 1749s for db, query in sql_strings["read_parameters"].items(): 1749s if db in conn: 1749s break 1749s else: 1749s raise KeyError(f"No part of {conn} found in sql_strings['read_parameters']") 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1164: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______________ test_read_iris_table[mysql_pymysql_engine_iris] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_iris_table(conn, request): 1749s # GH 51015 if conn = sqlite_iris_str 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_read_iris_table[mysql_pymysql_conn_iris] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_iris_table(conn, request): 1749s # GH 51015 if conn = sqlite_iris_str 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________ test_read_iris_table[postgresql_psycopg2_engine_iris] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_iris_table(conn, request): 1749s # GH 51015 if conn = sqlite_iris_str 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________ test_read_iris_table[postgresql_psycopg2_conn_iris] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_iris_table(conn, request): 1749s # GH 51015 if conn = sqlite_iris_str 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1172: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________ test_read_iris_table_chunksize[mysql_pymysql_engine_iris] ___________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_iris_table_chunksize(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_read_iris_table_chunksize[mysql_pymysql_conn_iris] ____________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_iris_table_chunksize(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______ test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] ________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_iris_table_chunksize(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________ test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] _________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_iris_table_chunksize(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1185: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________________ test_to_sql_callable[mysql_pymysql_engine] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_to_sql_callable(conn, test_frame1, request): 1749s conn = request.getfixturevalue(conn) 1749s 1749s check = [] # used to double check function below is really being used 1749s 1749s def sample(pd_table, conn, keys, data_iter): 1749s check.append(1) 1749s data = [dict(zip(keys, row)) for row in data_iter] 1749s conn.execute(pd_table.table.insert(), data) 1749s 1749s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________________ test_to_sql_callable[mysql_pymysql_conn] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_to_sql_callable(conn, test_frame1, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_to_sql_callable[postgresql_psycopg2_engine] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_to_sql_callable(conn, test_frame1, request): 1749s conn = request.getfixturevalue(conn) 1749s 1749s check = [] # used to double check function below is really being used 1749s 1749s def sample(pd_table, conn, keys, data_iter): 1749s check.append(1) 1749s data = [dict(zip(keys, row)) for row in data_iter] 1749s conn.execute(pd_table.table.insert(), data) 1749s 1749s > with pandasSQL_builder(conn, need_transaction=True) as pandasSQL: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1203: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_to_sql_callable[postgresql_psycopg2_conn] ________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_to_sql_callable(conn, test_frame1, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1194: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________ test_default_type_conversion[mysql_pymysql_engine_types] ___________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_default_type_conversion(conn, request): 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin_types": 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="sqlite_buildin connection does not implement read_sql_table" 1749s ) 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________ test_default_type_conversion[mysql_pymysql_conn_types] ____________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_default_type_conversion(conn, request): 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin_types": 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="sqlite_buildin connection does not implement read_sql_table" 1749s ) 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________ test_default_type_conversion[postgresql_psycopg2_engine_types] ________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_default_type_conversion(conn, request): 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin_types": 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="sqlite_buildin connection does not implement read_sql_table" 1749s ) 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________ test_default_type_conversion[postgresql_psycopg2_conn_types] _________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_default_type_conversion(conn, request): 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin_types": 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="sqlite_buildin connection does not implement read_sql_table" 1749s ) 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1220: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________________ test_read_procedure[mysql_pymysql_engine] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", mysql_connectable) 1749s def test_read_procedure(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s 1749s # GH 7324 1749s # Although it is more an api test, it is added to the 1749s # mysql tests as sqlite does not have stored procedures 1749s from sqlalchemy import text 1749s from sqlalchemy.engine import Engine 1749s 1749s df = DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3]}) 1749s > df.to_sql(name="test_frame", con=conn, index=False) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1253: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________________ test_read_procedure[mysql_pymysql_conn] ____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", mysql_connectable) 1749s def test_read_procedure(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1244: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s expected_count = 2 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1749s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1749s # GH 8953 1749s # Example in io.rst found under _io.sql.method 1749s # not available in sqlite, mysql 1749s def psql_insert_copy(table, conn, keys, data_iter): 1749s # gets a DBAPI connection that can provide a cursor 1749s dbapi_conn = conn.connection 1749s with dbapi_conn.cursor() as cur: 1749s s_buf = StringIO() 1749s writer = csv.writer(s_buf) 1749s writer.writerows(data_iter) 1749s s_buf.seek(0) 1749s 1749s columns = ", ".join([f'"{k}"' for k in keys]) 1749s if table.schema: 1749s table_name = f"{table.schema}.{table.name}" 1749s else: 1749s table_name = table.name 1749s 1749s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1749s cur.copy_expert(sql=sql_query, file=s_buf) 1749s return expected_count 1749s 1749s conn = request.getfixturevalue(conn) 1749s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 1749s > result_count = expected.to_sql( 1749s name="test_frame", con=conn, index=False, method=psql_insert_copy 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] _____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn', expected_count = 2 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1749s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1749s # GH 8953 1749s # Example in io.rst found under _io.sql.method 1749s # not available in sqlite, mysql 1749s def psql_insert_copy(table, conn, keys, data_iter): 1749s # gets a DBAPI connection that can provide a cursor 1749s dbapi_conn = conn.connection 1749s with dbapi_conn.cursor() as cur: 1749s s_buf = StringIO() 1749s writer = csv.writer(s_buf) 1749s writer.writerows(data_iter) 1749s s_buf.seek(0) 1749s 1749s columns = ", ".join([f'"{k}"' for k in keys]) 1749s if table.schema: 1749s table_name = f"{table.schema}.{table.name}" 1749s else: 1749s table_name = table.name 1749s 1749s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1749s cur.copy_expert(sql=sql_query, file=s_buf) 1749s return expected_count 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s expected_count = 'Success!' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1749s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1749s # GH 8953 1749s # Example in io.rst found under _io.sql.method 1749s # not available in sqlite, mysql 1749s def psql_insert_copy(table, conn, keys, data_iter): 1749s # gets a DBAPI connection that can provide a cursor 1749s dbapi_conn = conn.connection 1749s with dbapi_conn.cursor() as cur: 1749s s_buf = StringIO() 1749s writer = csv.writer(s_buf) 1749s writer.writerows(data_iter) 1749s s_buf.seek(0) 1749s 1749s columns = ", ".join([f'"{k}"' for k in keys]) 1749s if table.schema: 1749s table_name = f"{table.schema}.{table.name}" 1749s else: 1749s table_name = table.name 1749s 1749s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1749s cur.copy_expert(sql=sql_query, file=s_buf) 1749s return expected_count 1749s 1749s conn = request.getfixturevalue(conn) 1749s expected = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 1749s > result_count = expected.to_sql( 1749s name="test_frame", con=conn, index=False, method=psql_insert_copy 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1306: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn', expected_count = 'Success!' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s @pytest.mark.parametrize("expected_count", [2, "Success!"]) 1749s def test_copy_from_callable_insertion_method(conn, expected_count, request): 1749s # GH 8953 1749s # Example in io.rst found under _io.sql.method 1749s # not available in sqlite, mysql 1749s def psql_insert_copy(table, conn, keys, data_iter): 1749s # gets a DBAPI connection that can provide a cursor 1749s dbapi_conn = conn.connection 1749s with dbapi_conn.cursor() as cur: 1749s s_buf = StringIO() 1749s writer = csv.writer(s_buf) 1749s writer.writerows(data_iter) 1749s s_buf.seek(0) 1749s 1749s columns = ", ".join([f'"{k}"' for k in keys]) 1749s if table.schema: 1749s table_name = f"{table.schema}.{table.name}" 1749s else: 1749s table_name = table.name 1749s 1749s sql_query = f"COPY {table_name} ({columns}) FROM STDIN WITH CSV" 1749s cur.copy_expert(sql=sql_query, file=s_buf) 1749s return expected_count 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1304: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s def test_insertion_method_on_conflict_do_nothing(conn, request): 1749s # GH 15988: Example in to_sql docstring 1749s conn = request.getfixturevalue(conn) 1749s 1749s from sqlalchemy.dialects.postgresql import insert 1749s from sqlalchemy.engine import Engine 1749s from sqlalchemy.sql import text 1749s 1749s def insert_on_conflict(table, conn, keys, data_iter): 1749s data = [dict(zip(keys, row)) for row in data_iter] 1749s stmt = ( 1749s insert(table.table) 1749s .values(data) 1749s .on_conflict_do_nothing(index_elements=["a"]) 1749s ) 1749s result = conn.execute(stmt) 1749s return result.rowcount 1749s 1749s create_sql = text( 1749s """ 1749s CREATE TABLE test_insert_conflict ( 1749s a integer PRIMARY KEY, 1749s b numeric, 1749s c text 1749s ); 1749s """ 1749s ) 1749s if isinstance(conn, Engine): 1749s > with conn.connect() as con: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1347: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____ test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s def test_insertion_method_on_conflict_do_nothing(conn, request): 1749s # GH 15988: Example in to_sql docstring 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1321: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________ test_to_sql_on_public_schema[postgresql_psycopg2_engine] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_to_sql_on_public_schema(conn, request): 1749s if "sqlite" in conn or "mysql" in conn: 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="test for public schema only specific to postgresql" 1749s ) 1749s ) 1749s 1749s conn = request.getfixturevalue(conn) 1749s 1749s test_data = DataFrame([[1, 2.1, "a"], [2, 3.1, "b"]], columns=list("abc")) 1749s > test_data.to_sql( 1749s name="test_public_schema", 1749s con=conn, 1749s if_exists="append", 1749s index=False, 1749s schema="public", 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1388: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_to_sql_on_public_schema[postgresql_psycopg2_conn] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_to_sql_on_public_schema(conn, request): 1749s if "sqlite" in conn or "mysql" in conn: 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="test for public schema only specific to postgresql" 1749s ) 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1385: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________ test_insertion_method_on_conflict_update[mysql_pymysql_engine] ________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", mysql_connectable) 1749s def test_insertion_method_on_conflict_update(conn, request): 1749s # GH 14553: Example in to_sql docstring 1749s conn = request.getfixturevalue(conn) 1749s 1749s from sqlalchemy.dialects.mysql import insert 1749s from sqlalchemy.engine import Engine 1749s from sqlalchemy.sql import text 1749s 1749s def insert_on_conflict(table, conn, keys, data_iter): 1749s data = [dict(zip(keys, row)) for row in data_iter] 1749s stmt = insert(table.table).values(data) 1749s stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c) 1749s result = conn.execute(stmt) 1749s return result.rowcount 1749s 1749s create_sql = text( 1749s """ 1749s CREATE TABLE test_insert_conflict ( 1749s a INT PRIMARY KEY, 1749s b FLOAT, 1749s c VARCHAR(10) 1749s ); 1749s """ 1749s ) 1749s if isinstance(conn, Engine): 1749s > with conn.connect() as con: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1426: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________ test_insertion_method_on_conflict_update[mysql_pymysql_conn] _________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", mysql_connectable) 1749s def test_insertion_method_on_conflict_update(conn, request): 1749s # GH 14553: Example in to_sql docstring 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1403: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________ test_read_view_postgres[postgresql_psycopg2_engine] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s def test_read_view_postgres(conn, request): 1749s # GH 52969 1749s conn = request.getfixturevalue(conn) 1749s 1749s from sqlalchemy.engine import Engine 1749s from sqlalchemy.sql import text 1749s 1749s table_name = f"group_{uuid.uuid4().hex}" 1749s view_name = f"group_view_{uuid.uuid4().hex}" 1749s 1749s sql_stmt = text( 1749s f""" 1749s CREATE TABLE {table_name} ( 1749s group_id INTEGER, 1749s name TEXT 1749s ); 1749s INSERT INTO {table_name} VALUES 1749s (1, 'name'); 1749s CREATE VIEW {view_name} 1749s AS 1749s SELECT * FROM {table_name}; 1749s """ 1749s ) 1749s if isinstance(conn, Engine): 1749s > with conn.connect() as con: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1478: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_read_view_postgres[postgresql_psycopg2_conn] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s def test_read_view_postgres(conn, request): 1749s # GH 52969 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1456: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________ test_read_sql_iris_parameter[mysql_pymysql_engine_iris] ____________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 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=?'}} 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_iris_parameter(conn, request, sql_strings): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'params' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________ test_read_sql_iris_parameter[mysql_pymysql_conn_iris] _____________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 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=?'}} 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_iris_parameter(conn, request, sql_strings): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'params' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________ test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] _________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 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=?'}} 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_iris_parameter(conn, request, sql_strings): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'params' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________ test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] __________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 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=?'}} 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_iris_parameter(conn, request, sql_strings): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'params' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1555: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________ test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] _________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 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=?'}} 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'params' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________ test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] __________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 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=?'}} 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'params' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____ test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] ______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 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=?'}} 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'params' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______ test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] _______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 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=?'}} 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_iris_named_parameter(conn, request, sql_strings): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'params' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1575: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_read_sql_view[mysql_pymysql_engine_iris] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_read_sql_view(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_read_sql_view[mysql_pymysql_conn_iris] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_read_sql_view(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_read_sql_view[postgresql_psycopg2_engine_iris] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_read_sql_view(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_api_read_sql_view[postgresql_psycopg2_conn_iris] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_read_sql_view(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1605: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] _____ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_read_sql_with_chunksize_no_result(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____ test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_read_sql_with_chunksize_no_result(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_read_sql_with_chunksize_no_result(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __ test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_read_sql_with_chunksize_no_result(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1616: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________________ test_api_to_sql[mysql_pymysql_engine] _____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql(conn, request, test_frame1): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame1", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________________ test_api_to_sql[mysql_pymysql_conn] ______________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql(conn, request, test_frame1): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_api_to_sql[postgresql_psycopg2_engine] __________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql(conn, request, test_frame1): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame1", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1626: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________________ test_api_to_sql[postgresql_psycopg2_conn] ___________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql(conn, request, test_frame1): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1625: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________________ test_api_to_sql_fail[mysql_pymysql_engine] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_fail(conn, request, test_frame1): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame2", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________________ test_api_to_sql_fail[mysql_pymysql_conn] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_fail(conn, request, test_frame1): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_to_sql_fail[postgresql_psycopg2_engine] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_fail(conn, request, test_frame1): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame2", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1637: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_api_to_sql_fail[postgresql_psycopg2_conn] ________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_fail(conn, request, test_frame1): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1636: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_api_to_sql_replace[mysql_pymysql_engine] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_replace(conn, request, test_frame1): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame3", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_api_to_sql_replace[mysql_pymysql_conn] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_replace(conn, request, test_frame1): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________ test_api_to_sql_replace[postgresql_psycopg2_engine] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_replace(conn, request, test_frame1): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame3", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1652: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_to_sql_replace[postgresql_psycopg2_conn] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_replace(conn, request, test_frame1): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1651: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________________ test_api_to_sql_append[mysql_pymysql_engine] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_append(conn, request, test_frame1): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame4", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________________ test_api_to_sql_append[mysql_pymysql_conn] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_append(conn, request, test_frame1): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________ test_api_to_sql_append[postgresql_psycopg2_engine] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_append(conn, request, test_frame1): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame4", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1670: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______________ test_api_to_sql_append[postgresql_psycopg2_conn] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_append(conn, request, test_frame1): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1669: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_to_sql_type_mapping[mysql_pymysql_engine] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame3 = index A B 1749s 0 2000-01-03 00:00:00 2147483647 -1.987670 1749s 1 2000-01-04 00:00:00 -29 -0.041232 1749s 2 2000-01-05 00:00:00 20000 0.731168 1749s 3 2000-01-06 00:00:00 -290867 1.567621 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame5", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_to_sql_type_mapping[mysql_pymysql_conn] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame3 = index A B 1749s 0 2000-01-03 00:00:00 2147483647 -1.987670 1749s 1 2000-01-04 00:00:00 -29 -0.041232 1749s 2 2000-01-05 00:00:00 20000 0.731168 1749s 3 2000-01-06 00:00:00 -290867 1.567621 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_to_sql_type_mapping[postgresql_psycopg2_engine] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame3 = index A B 1749s 0 2000-01-03 00:00:00 2147483647 -1.987670 1749s 1 2000-01-04 00:00:00 -29 -0.041232 1749s 2 2000-01-05 00:00:00 20000 0.731168 1749s 3 2000-01-06 00:00:00 -290867 1.567621 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame5", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1689: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_api_to_sql_type_mapping[postgresql_psycopg2_conn] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame3 = index A B 1749s 0 2000-01-03 00:00:00 2147483647 -1.987670 1749s 1 2000-01-04 00:00:00 -29 -0.041232 1749s 2 2000-01-05 00:00:00 20000 0.731168 1749s 3 2000-01-06 00:00:00 -290867 1.567621 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_type_mapping(conn, request, test_frame3): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1688: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________________ test_api_to_sql_series[mysql_pymysql_engine] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_series(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_series", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________________ test_api_to_sql_series[mysql_pymysql_conn] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_series(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________ test_api_to_sql_series[postgresql_psycopg2_engine] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_series(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_series", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1702: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______________ test_api_to_sql_series[postgresql_psycopg2_conn] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_series(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1701: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________________ test_api_roundtrip[mysql_pymysql_engine] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_roundtrip(conn, request, test_frame1): 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame_roundtrip", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________________ test_api_roundtrip[mysql_pymysql_conn] ____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_roundtrip(conn, request, test_frame1): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_api_roundtrip[postgresql_psycopg2_engine] ________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_roundtrip(conn, request, test_frame1): 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame_roundtrip", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1716: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________________ test_api_roundtrip[postgresql_psycopg2_conn] _________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_roundtrip(conn, request, test_frame1): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1715: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_roundtrip_chunksize[mysql_pymysql_engine] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame_roundtrip", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_roundtrip_chunksize[mysql_pymysql_conn] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_roundtrip_chunksize[postgresql_psycopg2_engine] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_frame_roundtrip", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1740: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_api_roundtrip_chunksize[postgresql_psycopg2_conn] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_roundtrip_chunksize(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1739: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______________ test_api_execute_sql[mysql_pymysql_engine_iris] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_execute_sql(conn, request): 1749s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_api_execute_sql[mysql_pymysql_conn_iris] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_execute_sql(conn, request): 1749s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________ test_api_execute_sql[postgresql_psycopg2_engine_iris] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_execute_sql(conn, request): 1749s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________ test_api_execute_sql[postgresql_psycopg2_conn_iris] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_api_execute_sql(conn, request): 1749s # drop_sql = "DROP TABLE IF EXISTS test" # should already be done 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1758: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_date_parsing[mysql_pymysql_engine_types] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_api_date_parsing(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_date_parsing[mysql_pymysql_conn_types] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_api_date_parsing(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_date_parsing[postgresql_psycopg2_engine_types] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_api_date_parsing(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_api_date_parsing[postgresql_psycopg2_conn_types] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_api_date_parsing(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1769: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-ignore-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-raise-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-SELECT * FROM types-mode0-coerce-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = , text = 'SELECT * FROM types' 1749s mode = ('sqlalchemy', 'fallback'), error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1749s error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1749s error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1749s error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-ignore-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1749s error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-raise-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback'), error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1749s error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1749s error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1749s error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_query-SELECT * FROM types-mode2-coerce-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = 1749s text = 'SELECT * FROM types', mode = ('sqlalchemy', 'fallback') 1749s error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-ignore-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'ignore' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-raise-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'raise' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_engine_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-mysql_pymysql_conn_types] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_engine_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_custom_dateparsing_error[read_sql_table-types-sqlalchemy-coerce-postgresql_psycopg2_conn_types] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s read_sql = , text = 'types' 1749s mode = 'sqlalchemy', error = 'coerce' 1749s types_data_frame = TextCol DateCol ... IntColWithNull BoolColWithNull 1749s 0 first 2000-01-03 00:00:00 ... 1.0 0.0 1749s 1 first 2000-01-04 00:00:00 ... NaN NaN 1749s 1749s [2 rows x 9 columns] 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s @pytest.mark.parametrize("error", ["ignore", "raise", "coerce"]) 1749s @pytest.mark.parametrize( 1749s "read_sql, text, mode", 1749s [ 1749s (sql.read_sql, "SELECT * FROM types", ("sqlalchemy", "fallback")), 1749s (sql.read_sql, "types", ("sqlalchemy")), 1749s ( 1749s sql.read_sql_query, 1749s "SELECT * FROM types", 1749s ("sqlalchemy", "fallback"), 1749s ), 1749s (sql.read_sql_table, "types", ("sqlalchemy")), 1749s ], 1749s ) 1749s def test_api_custom_dateparsing_error( 1749s conn, request, read_sql, text, mode, error, types_data_frame 1749s ): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1841: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________ test_api_date_and_index[mysql_pymysql_engine_types] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_api_date_and_index(conn, request): 1749s # Test case where same column appears in parse_date and index_col 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________ test_api_date_and_index[mysql_pymysql_conn_types] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_api_date_and_index(conn, request): 1749s # Test case where same column appears in parse_date and index_col 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________ test_api_date_and_index[postgresql_psycopg2_engine_types] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_api_date_and_index(conn, request): 1749s # Test case where same column appears in parse_date and index_col 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________ test_api_date_and_index[postgresql_psycopg2_conn_types] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_types) 1749s def test_api_date_and_index(conn, request): 1749s # Test case where same column appears in parse_date and index_col 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1880: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________________ test_api_timedelta[mysql_pymysql_engine] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_timedelta(conn, request): 1749s # see #6921 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_timedelta", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________________ test_api_timedelta[mysql_pymysql_conn] ____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_timedelta(conn, request): 1749s # see #6921 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_api_timedelta[postgresql_psycopg2_engine] ________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_timedelta(conn, request): 1749s # see #6921 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_timedelta", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1897: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________________ test_api_timedelta[postgresql_psycopg2_conn] _________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_timedelta(conn, request): 1749s # see #6921 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1896: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_api_complex_raises[mysql_pymysql_engine] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_complex_raises(conn, request): 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame({"a": [1 + 1j, 2j]}) 1749s 1749s if "adbc" in conn_name: 1749s msg = "datatypes not supported" 1749s else: 1749s msg = "Complex datatypes not supported" 1749s with pytest.raises(ValueError, match=msg): 1749s > assert df.to_sql("test_complex", con=conn) is None 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_api_complex_raises[mysql_pymysql_conn] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_complex_raises(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________ test_api_complex_raises[postgresql_psycopg2_engine] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_complex_raises(conn, request): 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame({"a": [1 + 1j, 2j]}) 1749s 1749s if "adbc" in conn_name: 1749s msg = "datatypes not supported" 1749s else: 1749s msg = "Complex datatypes not supported" 1749s with pytest.raises(ValueError, match=msg): 1749s > assert df.to_sql("test_complex", con=conn) is None 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1950: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_complex_raises[postgresql_psycopg2_conn] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_complex_raises(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1942: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] _______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s index_name = None, index_label = None, expected = 'index' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______ test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] ________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s index_name = None, index_label = None, expected = 'index' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s index_name = None, index_label = None, expected = 'index' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____ test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] _____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s index_name = None, index_label = None, expected = 'index' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_engine] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s index_name = None, index_label = 'other_label', expected = 'other_label' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_to_sql_index_label[None-other_label-other_label-mysql_pymysql_conn] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s index_name = None, index_label = 'other_label', expected = 'other_label' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_engine] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s index_name = None, index_label = 'other_label', expected = 'other_label' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_to_sql_index_label[None-other_label-other_label-postgresql_psycopg2_conn] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s index_name = None, index_label = 'other_label', expected = 'other_label' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_engine] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s index_name = 'index_name', index_label = None, expected = 'index_name' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_api_to_sql_index_label[index_name-None-index_name-mysql_pymysql_conn] __ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s index_name = 'index_name', index_label = None, expected = 'index_name' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_engine] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s index_name = 'index_name', index_label = None, expected = 'index_name' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_to_sql_index_label[index_name-None-index_name-postgresql_psycopg2_conn] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s index_name = 'index_name', index_label = None, expected = 'index_name' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_engine] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_to_sql_index_label[index_name-other_label-other_label-mysql_pymysql_conn] _ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_engine] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _ test_api_to_sql_index_label[index_name-other_label-other_label-postgresql_psycopg2_conn] _ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s index_name = 'index_name', index_label = 'other_label', expected = 'other_label' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] __________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s index_name = 0, index_label = None, expected = '0' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] ___________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s index_name = 0, index_label = None, expected = '0' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] _______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s index_name = 0, index_label = None, expected = '0' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________ test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] ________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s index_name = 0, index_label = None, expected = '0' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] __________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s index_name = None, index_label = 0, expected = '0' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] ___________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s index_name = None, index_label = 0, expected = '0' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] _______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s index_name = None, index_label = 0, expected = '0' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1977: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________ test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] ________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s index_name = None, index_label = 0, expected = '0' 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "index_name,index_label,expected", 1749s [ 1749s # no index name, defaults to 'index' 1749s (None, None, "index"), 1749s # specifying index_label 1749s (None, "other_label", "other_label"), 1749s # using the index name 1749s ("index_name", None, "index_name"), 1749s # has index name, but specifying index_label 1749s ("index_name", "other_label", "other_label"), 1749s # index name is integer 1749s (0, None, "0"), 1749s # index name is None but index label is integer 1749s (None, 0, "0"), 1749s ], 1749s ) 1749s def test_api_to_sql_index_label(conn, request, index_name, index_label, expected): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:1976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] ______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_index_label_multiindex(conn, request): 1749s conn_name = conn 1749s if "mysql" in conn_name: 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="MySQL can fail using TEXT without length as key", strict=False 1749s ) 1749s ) 1749s elif "adbc" in conn_name: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_index_label", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2004: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______ test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] _______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_to_sql_index_label_multiindex(conn, request): 1749s conn_name = conn 1749s if "mysql" in conn_name: 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="MySQL can fail using TEXT without length as key", strict=False 1749s ) 1749s ) 1749s elif "adbc" in conn_name: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="index_label argument NotImplemented with ADBC") 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2003: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________ test_api_multiindex_roundtrip[mysql_pymysql_engine] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_multiindex_roundtrip(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_multiindex_roundtrip", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________ test_api_multiindex_roundtrip[mysql_pymysql_conn] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_multiindex_roundtrip(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________ test_api_multiindex_roundtrip[postgresql_psycopg2_engine] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_multiindex_roundtrip(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_multiindex_roundtrip", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2066: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________ test_api_multiindex_roundtrip[postgresql_psycopg2_conn] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_multiindex_roundtrip(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2065: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_dtype_argument[None-mysql_pymysql_engine] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s dtype = None 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_dtype_argument", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_dtype_argument[None-mysql_pymysql_conn] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s dtype = None 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_dtype_argument[None-postgresql_psycopg2_engine] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s dtype = None 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_dtype_argument", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_api_dtype_argument[None-postgresql_psycopg2_conn] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s dtype = None 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_dtype_argument[int-mysql_pymysql_engine] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s dtype = 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_dtype_argument", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_dtype_argument[int-mysql_pymysql_conn] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s dtype = 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_dtype_argument[int-postgresql_psycopg2_engine] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s dtype = 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_dtype_argument", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_api_dtype_argument[int-postgresql_psycopg2_conn] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s dtype = 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________ test_api_dtype_argument[float-mysql_pymysql_engine] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s dtype = 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_dtype_argument", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________ test_api_dtype_argument[float-mysql_pymysql_conn] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s dtype = 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________ test_api_dtype_argument[float-postgresql_psycopg2_engine] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s dtype = 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_dtype_argument", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________ test_api_dtype_argument[float-postgresql_psycopg2_conn] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s dtype = 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________ test_api_dtype_argument[dtype3-mysql_pymysql_engine] _____________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s dtype = {'A': , 'B': } 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_dtype_argument", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________ test_api_dtype_argument[dtype3-mysql_pymysql_conn] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s dtype = {'A': , 'B': } 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________ test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] __________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s dtype = {'A': , 'B': } 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_dtype_argument", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2097: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________ test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s dtype = {'A': , 'B': } 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s @pytest.mark.parametrize( 1749s "dtype", 1749s [ 1749s None, 1749s int, 1749s float, 1749s {"A": int, "B": float}, 1749s ], 1749s ) 1749s def test_api_dtype_argument(conn, request, dtype): 1749s # GH10285 Add dtype argument to read_sql_query 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2096: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______________ test_api_integer_col_names[mysql_pymysql_engine] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_integer_col_names(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 1749s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_api_integer_col_names[mysql_pymysql_conn] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_integer_col_names(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________ test_api_integer_col_names[postgresql_psycopg2_engine] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_integer_col_names(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([[1, 2], [3, 4]], columns=[0, 1]) 1749s > sql.to_sql(df, "test_frame_integer_col_names", conn, if_exists="replace") 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2119: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________ test_api_integer_col_names[postgresql_psycopg2_conn] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_integer_col_names(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2117: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________________ test_api_get_schema[mysql_pymysql_engine] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1749s with pandasSQL_builder(con=con) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________________ test_api_get_schema[mysql_pymysql_conn] ____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_get_schema[postgresql_psycopg2_engine] ________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > create_sql = sql.get_schema(test_frame1, "test", con=conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2132: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1749s with pandasSQL_builder(con=con) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_api_get_schema[postgresql_psycopg2_conn] _________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2131: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_api_get_schema_with_schema[mysql_pymysql_engine] _____________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_with_schema(conn, request, test_frame1): 1749s # GH28486 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1749s with pandasSQL_builder(con=con) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________ test_api_get_schema_with_schema[mysql_pymysql_conn] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_with_schema(conn, request, test_frame1): 1749s # GH28486 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________ test_api_get_schema_with_schema[postgresql_psycopg2_engine] __________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_with_schema(conn, request, test_frame1): 1749s # GH28486 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > create_sql = sql.get_schema(test_frame1, "test", con=conn, schema="pypi") 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2147: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1749s with pandasSQL_builder(con=con) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________ test_api_get_schema_with_schema[postgresql_psycopg2_conn] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_with_schema(conn, request, test_frame1): 1749s # GH28486 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______________ test_api_get_schema_dtypes[mysql_pymysql_engine] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_dtypes(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 1749s 1749s if conn_name == "sqlite_buildin": 1749s dtype = "INTEGER" 1749s else: 1749s from sqlalchemy import Integer 1749s 1749s dtype = Integer 1749s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1749s with pandasSQL_builder(con=con) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_api_get_schema_dtypes[mysql_pymysql_conn] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_dtypes(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________ test_api_get_schema_dtypes[postgresql_psycopg2_engine] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_dtypes(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s float_frame = DataFrame({"a": [1.1, 1.2], "b": [2.1, 2.2]}) 1749s 1749s if conn_name == "sqlite_buildin": 1749s dtype = "INTEGER" 1749s else: 1749s from sqlalchemy import Integer 1749s 1749s dtype = Integer 1749s > create_sql = sql.get_schema(float_frame, "test", con=conn, dtype={"b": dtype}) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2170: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1749s with pandasSQL_builder(con=con) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________ test_api_get_schema_dtypes[postgresql_psycopg2_conn] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_dtypes(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2161: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_api_get_schema_keys[mysql_pymysql_engine] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_keys(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 1749s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1749s with pandasSQL_builder(con=con) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_api_get_schema_keys[mysql_pymysql_conn] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_keys(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________ test_api_get_schema_keys[postgresql_psycopg2_engine] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_keys(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s frame = DataFrame({"Col1": [1.1, 1.2], "Col2": [2.1, 2.2]}) 1749s > create_sql = sql.get_schema(frame, "test", con=conn, keys="Col1") 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2187: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1749s with pandasSQL_builder(con=con) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_get_schema_keys[postgresql_psycopg2_conn] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_get_schema_keys(conn, request, test_frame1): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="'get_schema' not implemented for ADBC drivers", 1749s strict=True, 1749s ) 1749s ) 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2185: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_api_chunksize_read[mysql_pymysql_engine] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_chunksize_read(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_chunksize", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_api_chunksize_read[mysql_pymysql_conn] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_chunksize_read(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________ test_api_chunksize_read[postgresql_psycopg2_engine] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_chunksize_read(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_chunksize", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2212: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_chunksize_read[postgresql_psycopg2_conn] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_chunksize_read(conn, request): 1749s if "adbc" in conn: 1749s request.node.add_marker( 1749s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1749s ) 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2211: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________________ test_api_categorical[mysql_pymysql_engine] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_categorical(conn, request): 1749s if conn == "postgresql_adbc_conn": 1749s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1749s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="categorical dtype not implemented for ADBC postgres driver", 1749s strict=True, 1749s ) 1749s ) 1749s # GH8624 1749s # test that categorical gets written correctly as dense column 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_categorical", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________________ test_api_categorical[mysql_pymysql_conn] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_categorical(conn, request): 1749s if conn == "postgresql_adbc_conn": 1749s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1749s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="categorical dtype not implemented for ADBC postgres driver", 1749s strict=True, 1749s ) 1749s ) 1749s # GH8624 1749s # test that categorical gets written correctly as dense column 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_categorical[postgresql_psycopg2_engine] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_categorical(conn, request): 1749s if conn == "postgresql_adbc_conn": 1749s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1749s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="categorical dtype not implemented for ADBC postgres driver", 1749s strict=True, 1749s ) 1749s ) 1749s # GH8624 1749s # test that categorical gets written correctly as dense column 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_categorical", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2267: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_api_categorical[postgresql_psycopg2_conn] ________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_categorical(conn, request): 1749s if conn == "postgresql_adbc_conn": 1749s adbc = import_optional_dependency("adbc_driver_postgresql", errors="ignore") 1749s if adbc is not None and Version(adbc.__version__) < Version("0.9.0"): 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="categorical dtype not implemented for ADBC postgres driver", 1749s strict=True, 1749s ) 1749s ) 1749s # GH8624 1749s # test that categorical gets written correctly as dense column 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2266: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_unicode_column_name[mysql_pymysql_engine] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_unicode_column_name(conn, request): 1749s # GH 11431 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_unicode", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_unicode_column_name[mysql_pymysql_conn] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_unicode_column_name(conn, request): 1749s # GH 11431 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_unicode_column_name[postgresql_psycopg2_engine] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_unicode_column_name(conn, request): 1749s # GH 11431 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_unicode", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2290: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_api_unicode_column_name[postgresql_psycopg2_conn] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_unicode_column_name(conn, request): 1749s # GH 11431 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2289: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_api_escaped_table_name[mysql_pymysql_engine] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_escaped_table_name(conn, request): 1749s # GH 13206 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_api_escaped_table_name[mysql_pymysql_conn] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_escaped_table_name(conn, request): 1749s # GH 13206 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_escaped_table_name[postgresql_psycopg2_engine] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_escaped_table_name(conn, request): 1749s # GH 13206 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("d1187b08-4943-4c8d-a7f6", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2303: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_api_escaped_table_name[postgresql_psycopg2_conn] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_escaped_table_name(conn, request): 1749s # GH 13206 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2302: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________ test_api_read_sql_duplicate_columns[mysql_pymysql_engine] ___________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_read_sql_duplicate_columns(conn, request): 1749s # GH#53117 1749s if "adbc" in conn: 1749s pa = pytest.importorskip("pyarrow") 1749s if not ( 1749s Version(pa.__version__) >= Version("16.0") 1749s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1749s ): 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="pyarrow->pandas throws ValueError", strict=True 1749s ) 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_table", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_api_read_sql_duplicate_columns[mysql_pymysql_conn] ____________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_read_sql_duplicate_columns(conn, request): 1749s # GH#53117 1749s if "adbc" in conn: 1749s pa = pytest.importorskip("pyarrow") 1749s if not ( 1749s Version(pa.__version__) >= Version("16.0") 1749s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1749s ): 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="pyarrow->pandas throws ValueError", strict=True 1749s ) 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______ test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] ________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_read_sql_duplicate_columns(conn, request): 1749s # GH#53117 1749s if "adbc" in conn: 1749s pa = pytest.importorskip("pyarrow") 1749s if not ( 1749s Version(pa.__version__) >= Version("16.0") 1749s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1749s ): 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="pyarrow->pandas throws ValueError", strict=True 1749s ) 1749s ) 1749s conn = request.getfixturevalue(conn) 1749s > if sql.has_table("test_table", conn): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2334: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:878: in has_table 1749s with pandasSQL_builder(con, schema=schema) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________ test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] _________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_api_read_sql_duplicate_columns(conn, request): 1749s # GH#53117 1749s if "adbc" in conn: 1749s pa = pytest.importorskip("pyarrow") 1749s if not ( 1749s Version(pa.__version__) >= Version("16.0") 1749s and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"] 1749s ): 1749s request.node.add_marker( 1749s pytest.mark.xfail( 1749s reason="pyarrow->pandas throws ValueError", strict=True 1749s ) 1749s ) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2333: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_read_table_columns[mysql_pymysql_engine] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_read_table_columns(conn, request, test_frame1): 1749s # test columns argument in read_table 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s conn = request.getfixturevalue(conn) 1749s > sql.to_sql(test_frame1, "test_frame", conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_read_table_columns[mysql_pymysql_conn] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_read_table_columns(conn, request, test_frame1): 1749s # test columns argument in read_table 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________ test_read_table_columns[postgresql_psycopg2_engine] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_read_table_columns(conn, request, test_frame1): 1749s # test columns argument in read_table 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s conn = request.getfixturevalue(conn) 1749s > sql.to_sql(test_frame1, "test_frame", conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2357: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_read_table_columns[postgresql_psycopg2_conn] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_read_table_columns(conn, request, test_frame1): 1749s # test columns argument in read_table 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2356: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______________ test_read_table_index_col[mysql_pymysql_engine] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_read_table_index_col(conn, request, test_frame1): 1749s # test columns argument in read_table 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s conn = request.getfixturevalue(conn) 1749s > sql.to_sql(test_frame1, "test_frame", conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_read_table_index_col[mysql_pymysql_conn] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_read_table_index_col(conn, request, test_frame1): 1749s # test columns argument in read_table 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________ test_read_table_index_col[postgresql_psycopg2_engine] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_read_table_index_col(conn, request, test_frame1): 1749s # test columns argument in read_table 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s conn = request.getfixturevalue(conn) 1749s > sql.to_sql(test_frame1, "test_frame", conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2373: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________ test_read_table_index_col[postgresql_psycopg2_conn] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_read_table_index_col(conn, request, test_frame1): 1749s # test columns argument in read_table 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2372: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_read_sql_delegate[mysql_pymysql_engine_iris] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_delegate(conn, request): 1749s if conn == "sqlite_buildin_iris": 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="sqlite_buildin connection does not implement read_sql_table" 1749s ) 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_read_sql_delegate[mysql_pymysql_conn_iris] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_delegate(conn, request): 1749s if conn == "sqlite_buildin_iris": 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="sqlite_buildin connection does not implement read_sql_table" 1749s ) 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_read_sql_delegate[postgresql_psycopg2_engine_iris] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_delegate(conn, request): 1749s if conn == "sqlite_buildin_iris": 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="sqlite_buildin connection does not implement read_sql_table" 1749s ) 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_read_sql_delegate[postgresql_psycopg2_conn_iris] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_read_sql_delegate(conn, request): 1749s if conn == "sqlite_buildin_iris": 1749s request.applymarker( 1749s pytest.mark.xfail( 1749s reason="sqlite_buildin connection does not implement read_sql_table" 1749s ) 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2397: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________ test_warning_case_insensitive_table_name[mysql_pymysql_engine] ________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1749s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1749s 1749s conn = request.getfixturevalue(conn) 1749s # see gh-7815 1749s with tm.assert_produces_warning( 1749s UserWarning, 1749s match=( 1749s r"The provided table name 'TABLE1' is not found exactly as such in " 1749s r"the database after writing the table, possibly due to case " 1749s r"sensitivity issues. Consider using lower case table names." 1749s ), 1749s ): 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1749s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1749s 1749s conn = request.getfixturevalue(conn) 1749s # see gh-7815 1749s > with tm.assert_produces_warning( 1749s UserWarning, 1749s match=( 1749s r"The provided table name 'TABLE1' is not found exactly as such in " 1749s r"the database after writing the table, possibly due to case " 1749s r"sensitivity issues. Consider using lower case table names." 1749s ), 1749s ): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/contextlib.py:162: in __exit__ 1749s self.gen.throw(value) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s def _assert_caught_expected_warning( 1749s *, 1749s caught_warnings: Sequence[warnings.WarningMessage], 1749s expected_warning: type[Warning], 1749s match: str | None, 1749s check_stacklevel: bool, 1749s ) -> None: 1749s """Assert that there was the expected warning among the caught warnings.""" 1749s saw_warning = False 1749s matched_message = False 1749s unmatched_messages = [] 1749s 1749s for actual_warning in caught_warnings: 1749s if issubclass(actual_warning.category, expected_warning): 1749s saw_warning = True 1749s 1749s if check_stacklevel: 1749s _assert_raised_with_correct_stacklevel(actual_warning) 1749s 1749s if match is not None: 1749s if re.search(match, str(actual_warning.message)): 1749s matched_message = True 1749s else: 1749s unmatched_messages.append(actual_warning.message) 1749s 1749s if not saw_warning: 1749s > raise AssertionError( 1749s f"Did not see expected warning of class " 1749s f"{repr(expected_warning.__name__)}" 1749s ) 1749s E AssertionError: Did not see expected warning of class 'UserWarning' 1749s 1749s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 1749s _________ test_warning_case_insensitive_table_name[mysql_pymysql_conn] _________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1749s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____ test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] _____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1749s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1749s 1749s conn = request.getfixturevalue(conn) 1749s # see gh-7815 1749s with tm.assert_produces_warning( 1749s UserWarning, 1749s match=( 1749s r"The provided table name 'TABLE1' is not found exactly as such in " 1749s r"the database after writing the table, possibly due to case " 1749s r"sensitivity issues. Consider using lower case table names." 1749s ), 1749s ): 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2448: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1749s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1749s 1749s conn = request.getfixturevalue(conn) 1749s # see gh-7815 1749s > with tm.assert_produces_warning( 1749s UserWarning, 1749s match=( 1749s r"The provided table name 'TABLE1' is not found exactly as such in " 1749s r"the database after writing the table, possibly due to case " 1749s r"sensitivity issues. Consider using lower case table names." 1749s ), 1749s ): 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2440: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/contextlib.py:162: in __exit__ 1749s self.gen.throw(value) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s def _assert_caught_expected_warning( 1749s *, 1749s caught_warnings: Sequence[warnings.WarningMessage], 1749s expected_warning: type[Warning], 1749s match: str | None, 1749s check_stacklevel: bool, 1749s ) -> None: 1749s """Assert that there was the expected warning among the caught warnings.""" 1749s saw_warning = False 1749s matched_message = False 1749s unmatched_messages = [] 1749s 1749s for actual_warning in caught_warnings: 1749s if issubclass(actual_warning.category, expected_warning): 1749s saw_warning = True 1749s 1749s if check_stacklevel: 1749s _assert_raised_with_correct_stacklevel(actual_warning) 1749s 1749s if match is not None: 1749s if re.search(match, str(actual_warning.message)): 1749s matched_message = True 1749s else: 1749s unmatched_messages.append(actual_warning.message) 1749s 1749s if not saw_warning: 1749s > raise AssertionError( 1749s f"Did not see expected warning of class " 1749s f"{repr(expected_warning.__name__)}" 1749s ) 1749s E AssertionError: Did not see expected warning of class 'UserWarning' 1749s 1749s /usr/lib/python3/dist-packages/pandas/_testing/_warnings.py:152: AssertionError 1749s ______ test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] ______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_warning_case_insensitive_table_name(conn, request, test_frame1): 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin" or "adbc" in conn_name: 1749s request.applymarker(pytest.mark.xfail(reason="Does not raise warning")) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2438: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_sqlalchemy_type_mapping[mysql_pymysql_engine] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_sqlalchemy_type_mapping(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s from sqlalchemy import TIMESTAMP 1749s 1749s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 1749s df = DataFrame( 1749s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 1749s ) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_sqlalchemy_type_mapping[mysql_pymysql_conn] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_sqlalchemy_type_mapping(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_sqlalchemy_type_mapping(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s from sqlalchemy import TIMESTAMP 1749s 1749s # Test Timestamp objects (no datetime64 because of timezone) (GH9085) 1749s df = DataFrame( 1749s {"time": to_datetime(["2014-12-12 01:54", "2014-12-11 02:54"], utc=True)} 1749s ) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2465: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_sqlalchemy_type_mapping(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2458: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'int8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] _______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'int8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'int8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'int8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'Int8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] _______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'Int8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'Int8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'Int8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] _____ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'uint8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'uint8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'uint8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'uint8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] _____ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'UInt8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'UInt8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'UInt8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'UInt8', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] _____ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'int16', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'int16', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'int16', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'int16', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] _____ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'Int16', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'Int16', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'Int16', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'Int16', expected = 'SMALLINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] _____ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'uint16', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'uint16', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'uint16', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'uint16', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] _____ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'UInt16', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'UInt16', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'UInt16', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'UInt16', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'int32', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] _______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'int32', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'int32', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'int32', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'Int32', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] _______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'Int32', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'Int32', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'Int32', expected = 'INTEGER' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'uint32', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] _______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'uint32', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'uint32', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'uint32', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'UInt32', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] _______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'UInt32', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'UInt32', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'UInt32', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'int64', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______ test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] _______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'int64', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'int64', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____ test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'int64', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'Int64', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______ test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] _______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'Int64', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'Int64', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____ test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'Int64', expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] _______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = , expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________ test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] ________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = , expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = , expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2496: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____ test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] _____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = , expected = 'BIGINT' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize( 1749s "integer, expected", 1749s [ 1749s ("int8", "SMALLINT"), 1749s ("Int8", "SMALLINT"), 1749s ("uint8", "SMALLINT"), 1749s ("UInt8", "SMALLINT"), 1749s ("int16", "SMALLINT"), 1749s ("Int16", "SMALLINT"), 1749s ("uint16", "INTEGER"), 1749s ("UInt16", "INTEGER"), 1749s ("int32", "INTEGER"), 1749s ("Int32", "INTEGER"), 1749s ("uint32", "BIGINT"), 1749s ("UInt32", "BIGINT"), 1749s ("int64", "BIGINT"), 1749s ("Int64", "BIGINT"), 1749s (int, "BIGINT" if np.dtype(int).name == "int64" else "INTEGER"), 1749s ], 1749s ) 1749s def test_sqlalchemy_integer_mapping(conn, request, integer, expected): 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2494: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] _____ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'uint64' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1749s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1749s conn = request.getfixturevalue(conn) 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____ test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'uint64' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1749s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'uint64' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1749s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1749s conn = request.getfixturevalue(conn) 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __ test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'uint64' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1749s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] _____ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s integer = 'UInt64' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1749s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1749s conn = request.getfixturevalue(conn) 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____ test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] ______ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s integer = 'UInt64' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1749s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s integer = 'UInt64' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1749s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1749s conn = request.getfixturevalue(conn) 1749s # GH35076 Map pandas integer to optimal SQLAlchemy integer type 1749s df = DataFrame([0, 1], columns=["a"], dtype=integer) 1749s > with sql.SQLDatabase(conn) as db: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2509: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __ test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s integer = 'UInt64' 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s @pytest.mark.parametrize("integer", ["uint64", "UInt64"]) 1749s def test_sqlalchemy_integer_overload_mapping(conn, request, integer): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2506: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________________ test_database_uri_string[mysql_pymysql_conn] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_database_uri_string(conn, request, test_frame1): 1749s td.versioned_importorskip("sqlalchemy") 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________ test_database_uri_string[postgresql_psycopg2_conn] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_database_uri_string(conn, request, test_frame1): 1749s td.versioned_importorskip("sqlalchemy") 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2519: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________ test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] _________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @td.skip_if_installed("pg8000") 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 1749s td.versioned_importorskip("sqlalchemy") 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] ______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @td.skip_if_installed("pg8000") 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_pg8000_sqlalchemy_passthrough_error(conn, request): 1749s td.versioned_importorskip("sqlalchemy") 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2541: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_query_by_text_obj[mysql_pymysql_engine_iris] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_query_by_text_obj(conn, request): 1749s # WIP : GH10846 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_query_by_text_obj[mysql_pymysql_conn_iris] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_query_by_text_obj(conn, request): 1749s # WIP : GH10846 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_query_by_text_obj[postgresql_psycopg2_engine_iris] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_query_by_text_obj(conn, request): 1749s # WIP : GH10846 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_query_by_text_obj[postgresql_psycopg2_conn_iris] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_query_by_text_obj(conn, request): 1749s # WIP : GH10846 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2553: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________ test_query_by_select_obj[mysql_pymysql_engine_iris] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_query_by_select_obj(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________ test_query_by_select_obj[mysql_pymysql_conn_iris] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_query_by_select_obj(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________ test_query_by_select_obj[postgresql_psycopg2_engine_iris] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_query_by_select_obj(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________ test_query_by_select_obj[postgresql_psycopg2_conn_iris] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_query_by_select_obj(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2567: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_column_with_percentage[mysql_pymysql_engine] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_column_with_percentage(conn, request): 1749s # GH 37157 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 1749s > df.to_sql(name="test_column_percentage", con=conn, index=False) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_column_with_percentage[mysql_pymysql_conn] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_column_with_percentage(conn, request): 1749s # GH 37157 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_column_with_percentage[postgresql_psycopg2_engine] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_column_with_percentage(conn, request): 1749s # GH 37157 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame({"A": [0, 1, 2], "%_variation": [3, 4, 5]}) 1749s > df.to_sql(name="test_column_percentage", con=conn, index=False) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2590: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_column_with_percentage[postgresql_psycopg2_conn] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_column_with_percentage(conn, request): 1749s # GH 37157 1749s conn_name = conn 1749s if conn_name == "sqlite_buildin": 1749s request.applymarker(pytest.mark.xfail(reason="Not Implemented")) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2588: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________________ test_create_table[mysql_pymysql_engine] ____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_create_table(conn, request): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s conn = request.getfixturevalue(conn) 1749s 1749s from sqlalchemy import inspect 1749s 1749s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1749s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________________ test_create_table[mysql_pymysql_conn] _____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_create_table(conn, request): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_create_table[postgresql_psycopg2_engine] _________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_create_table(conn, request): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s conn = request.getfixturevalue(conn) 1749s 1749s from sqlalchemy import inspect 1749s 1749s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1749s > with sql.SQLDatabase(conn, need_transaction=True) as pandasSQL: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2681: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________________ test_create_table[postgresql_psycopg2_conn] __________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_create_table(conn, request): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2676: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________________ test_drop_table[mysql_pymysql_engine] _____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_drop_table(conn, request): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s conn = request.getfixturevalue(conn) 1749s 1749s from sqlalchemy import inspect 1749s 1749s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1749s > with sql.SQLDatabase(conn) as pandasSQL: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________________ test_drop_table[mysql_pymysql_conn] ______________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_drop_table(conn, request): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_drop_table[postgresql_psycopg2_engine] __________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_drop_table(conn, request): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s conn = request.getfixturevalue(conn) 1749s 1749s from sqlalchemy import inspect 1749s 1749s temp_frame = DataFrame({"one": [1.0, 2.0, 3.0, 4.0], "two": [4.0, 3.0, 2.0, 1.0]}) 1749s > with sql.SQLDatabase(conn) as pandasSQL: 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2702: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________________ test_drop_table[postgresql_psycopg2_conn] ___________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_drop_table(conn, request): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2697: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________________ test_roundtrip[mysql_pymysql_engine] _____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_roundtrip(conn, request, test_frame1): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > pandasSQL = pandasSQL_builder(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________________ test_roundtrip[mysql_pymysql_conn] ______________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_roundtrip(conn, request, test_frame1): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________________ test_roundtrip[postgresql_psycopg2_engine] __________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_roundtrip(conn, request, test_frame1): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s > pandasSQL = pandasSQL_builder(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2725: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________________ test_roundtrip[postgresql_psycopg2_conn] ___________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s test_frame1 = index A B C D 1749s 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 1749s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1749s 1749s @pytest.mark.parametrize("conn", all_connectable) 1749s def test_roundtrip(conn, request, test_frame1): 1749s if conn == "sqlite_str": 1749s pytest.skip("sqlite_str has no inspection system") 1749s 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2724: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________________ test_execute_sql[mysql_pymysql_engine_iris] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_execute_sql(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________________ test_execute_sql[mysql_pymysql_conn_iris] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_execute_sql(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________ test_execute_sql[postgresql_psycopg2_engine_iris] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_execute_sql(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______________ test_execute_sql[postgresql_psycopg2_conn_iris] ________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", all_connectable_iris) 1749s def test_execute_sql(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2742: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_sqlalchemy_read_table[mysql_pymysql_engine_iris] _____________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_sqlalchemy_read_table(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________ test_sqlalchemy_read_table[mysql_pymysql_conn_iris] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_sqlalchemy_read_table(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________ test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] __________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_sqlalchemy_read_table(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________ test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_sqlalchemy_read_table(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2753: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________ test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] _________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_sqlalchemy_read_table_columns(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________ test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] __________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_sqlalchemy_read_table_columns(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____ test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] ______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_sqlalchemy_read_table_columns(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______ test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] _______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_sqlalchemy_read_table_columns(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2760: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________ test_read_table_absent_raises[mysql_pymysql_engine_iris] ___________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_table_absent_raises(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________ test_read_table_absent_raises[mysql_pymysql_conn_iris] ____________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_table_absent_raises(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:621: in mysql_pymysql_engine_iris 1749s create_and_load_iris(mysql_pymysql_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________ test_read_table_absent_raises[postgresql_psycopg2_engine_iris] ________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_table_absent_raises(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________ test_read_table_absent_raises[postgresql_psycopg2_conn_iris] _________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_iris' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_iris) 1749s def test_read_table_absent_raises(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2769: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:668: in postgresql_psycopg2_engine_iris 1749s create_and_load_iris(postgresql_psycopg2_engine, iris_path) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:198: in create_and_load_iris 1749s with conn.begin() as con: 1749s /usr/lib/python3.13/contextlib.py:141: in __enter__ 1749s return next(self.gen) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3238: in begin 1749s with self.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1749s def test_sqlalchemy_default_type_conversion(conn, request): 1749s conn_name = conn 1749s if conn_name == "sqlite_str": 1749s pytest.skip("types tables not created in sqlite_str fixture") 1749s elif "mysql" in conn_name or "sqlite" in conn_name: 1749s request.applymarker( 1749s pytest.mark.xfail(reason="boolean dtype not inferred properly") 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1749s def test_sqlalchemy_default_type_conversion(conn, request): 1749s conn_name = conn 1749s if conn_name == "sqlite_str": 1749s pytest.skip("types tables not created in sqlite_str fixture") 1749s elif "mysql" in conn_name or "sqlite" in conn_name: 1749s request.applymarker( 1749s pytest.mark.xfail(reason="boolean dtype not inferred properly") 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2785: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________________ test_bigint[mysql_pymysql_engine] _______________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_bigint(conn, request): 1749s # int64 should be converted to BigInteger, GH7433 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame(data={"i64": [2**62]}) 1749s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________________ test_bigint[mysql_pymysql_conn] ________________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_bigint(conn, request): 1749s # int64 should be converted to BigInteger, GH7433 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________________ test_bigint[postgresql_psycopg2_engine] ____________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_bigint(conn, request): 1749s # int64 should be converted to BigInteger, GH7433 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame(data={"i64": [2**62]}) 1749s > assert df.to_sql(name="test_bigint", con=conn, index=False) == 1 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2803: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________________ test_bigint[postgresql_psycopg2_conn] _____________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_bigint(conn, request): 1749s # int64 should be converted to BigInteger, GH7433 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2801: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_default_date_load[mysql_pymysql_engine_types] ______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1749s def test_default_date_load(conn, request): 1749s conn_name = conn 1749s if conn_name == "sqlite_str": 1749s pytest.skip("types tables not created in sqlite_str fixture") 1749s elif "sqlite" in conn_name: 1749s request.applymarker( 1749s pytest.mark.xfail(reason="sqlite does not read date properly") 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_default_date_load[mysql_pymysql_conn_types] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1749s def test_default_date_load(conn, request): 1749s conn_name = conn 1749s if conn_name == "sqlite_str": 1749s pytest.skip("types tables not created in sqlite_str fixture") 1749s elif "sqlite" in conn_name: 1749s request.applymarker( 1749s pytest.mark.xfail(reason="sqlite does not read date properly") 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_default_date_load[postgresql_psycopg2_engine_types] ___________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1749s def test_default_date_load(conn, request): 1749s conn_name = conn 1749s if conn_name == "sqlite_str": 1749s pytest.skip("types tables not created in sqlite_str fixture") 1749s elif "sqlite" in conn_name: 1749s request.applymarker( 1749s pytest.mark.xfail(reason="sqlite does not read date properly") 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_default_date_load[postgresql_psycopg2_conn_types] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1749s def test_default_date_load(conn, request): 1749s conn_name = conn 1749s if conn_name == "sqlite_str": 1749s pytest.skip("types tables not created in sqlite_str fixture") 1749s elif "sqlite" in conn_name: 1749s request.applymarker( 1749s pytest.mark.xfail(reason="sqlite does not read date properly") 1749s ) 1749s 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2819: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______ test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] ______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s parse_dates = None 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1749s def test_datetime_with_timezone_query(conn, request, parse_dates): 1749s # edge case that converts postgresql datetime with time zone types 1749s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1749s # but should be more natural, so coerce to datetime64[ns] for now 1749s conn = request.getfixturevalue(conn) 1749s > expected = create_and_load_postgres_datetz(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______ test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] _______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s parse_dates = None 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1749s def test_datetime_with_timezone_query(conn, request, parse_dates): 1749s # edge case that converts postgresql datetime with time zone types 1749s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1749s # but should be more natural, so coerce to datetime64[ns] for now 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] __ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s parse_dates = ['DateColWithTz'] 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1749s def test_datetime_with_timezone_query(conn, request, parse_dates): 1749s # edge case that converts postgresql datetime with time zone types 1749s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1749s # but should be more natural, so coerce to datetime64[ns] for now 1749s conn = request.getfixturevalue(conn) 1749s > expected = create_and_load_postgres_datetz(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2832: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] ___ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s parse_dates = ['DateColWithTz'] 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s @pytest.mark.parametrize("parse_dates", [None, ["DateColWithTz"]]) 1749s def test_datetime_with_timezone_query(conn, request, parse_dates): 1749s # edge case that converts postgresql datetime with time zone types 1749s # to datetime64[ns,psycopg2.tz.FixedOffsetTimezone..], which is ok 1749s # but should be more natural, so coerce to datetime64[ns] for now 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2831: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] ____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s def test_datetime_with_timezone_query_chunksize(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s > expected = create_and_load_postgres_datetz(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2843: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____ test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] _____ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s def test_datetime_with_timezone_query_chunksize(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2842: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________ test_datetime_with_timezone_table[postgresql_psycopg2_engine] _________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s def test_datetime_with_timezone_table(conn, request): 1749s conn = request.getfixturevalue(conn) 1749s > expected = create_and_load_postgres_datetz(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2856: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:351: in create_and_load_postgres_datetz 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________ test_datetime_with_timezone_table[postgresql_psycopg2_conn] __________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", postgresql_connectable) 1749s def test_datetime_with_timezone_table(conn, request): 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2855: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________ test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] __________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_with_timezone_roundtrip(conn, request): 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s # GH 9086 1749s # Write datetimetz data to a db and read it back 1749s # For dbs that support timestamps with timezones, should get back UTC 1749s # otherwise naive data should be returned 1749s expected = DataFrame( 1749s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 1749s ) 1749s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________ test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] ___________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_with_timezone_roundtrip(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] _______ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_with_timezone_roundtrip(conn, request): 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s # GH 9086 1749s # Write datetimetz data to a db and read it back 1749s # For dbs that support timestamps with timezones, should get back UTC 1749s # otherwise naive data should be returned 1749s expected = DataFrame( 1749s {"A": date_range("2013-01-01 09:00:00", periods=3, tz="US/Pacific")} 1749s ) 1749s > assert expected.to_sql(name="test_datetime_tz", con=conn, index=False) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2872: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _______ test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] ________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_with_timezone_roundtrip(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2864: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_out_of_bounds_datetime[mysql_pymysql_engine] _______________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_out_of_bounds_datetime(conn, request): 1749s # GH 26761 1749s conn = request.getfixturevalue(conn) 1749s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 1749s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_out_of_bounds_datetime[mysql_pymysql_conn] ________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_out_of_bounds_datetime(conn, request): 1749s # GH 26761 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________ test_out_of_bounds_datetime[postgresql_psycopg2_engine] ____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_out_of_bounds_datetime(conn, request): 1749s # GH 26761 1749s conn = request.getfixturevalue(conn) 1749s data = DataFrame({"date": datetime(9999, 1, 1)}, index=[0]) 1749s > assert data.to_sql(name="test_datetime_obb", con=conn, index=False) == 1 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2897: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________ test_out_of_bounds_datetime[postgresql_psycopg2_conn] _____________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_out_of_bounds_datetime(conn, request): 1749s # GH 26761 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2895: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________ test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] ___________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_naive_datetimeindex_roundtrip(conn, request): 1749s # GH 23510 1749s # Ensure that a naive DatetimeIndex isn't converted to UTC 1749s conn = request.getfixturevalue(conn) 1749s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 1749s expected = DataFrame({"nums": range(5)}, index=dates) 1749s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________ test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] ____________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_naive_datetimeindex_roundtrip(conn, request): 1749s # GH 23510 1749s # Ensure that a naive DatetimeIndex isn't converted to UTC 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] ________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_naive_datetimeindex_roundtrip(conn, request): 1749s # GH 23510 1749s # Ensure that a naive DatetimeIndex isn't converted to UTC 1749s conn = request.getfixturevalue(conn) 1749s dates = date_range("2018-01-01", periods=5, freq="6h")._with_freq(None) 1749s expected = DataFrame({"nums": range(5)}, index=dates) 1749s > assert expected.to_sql(name="foo_table", con=conn, index_label="info_date") == 5 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2910: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________ test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] _________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_naive_datetimeindex_roundtrip(conn, request): 1749s # GH 23510 1749s # Ensure that a naive DatetimeIndex isn't converted to UTC 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2907: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_date_parsing[mysql_pymysql_engine_types] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1749s def test_date_parsing(conn, request): 1749s # No Parsing 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_date_parsing[mysql_pymysql_conn_types] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1749s def test_date_parsing(conn, request): 1749s # No Parsing 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:628: in mysql_pymysql_engine_types 1749s create_and_load_types(mysql_pymysql_engine, types_data, "mysql") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________ test_date_parsing[postgresql_psycopg2_engine_types] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_engine_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1749s def test_date_parsing(conn, request): 1749s # No Parsing 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_date_parsing[postgresql_psycopg2_conn_types] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn_types' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable_types) 1749s def test_date_parsing(conn, request): 1749s # No Parsing 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2920: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1047: in execute 1749s fixturedef = request._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:675: in postgresql_psycopg2_engine_types 1749s create_and_load_types(postgresql_psycopg2_engine, types_data, "postgres") 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:317: in create_and_load_types 1749s with conn.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _____________________ test_datetime[mysql_pymysql_engine] ______________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime(conn, request): 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame( 1749s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1749s ) 1749s > assert df.to_sql(name="test_datetime", con=conn) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ______________________ test_datetime[mysql_pymysql_conn] _______________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s __________________ test_datetime[postgresql_psycopg2_engine] ___________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime(conn, request): 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame( 1749s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1749s ) 1749s > assert df.to_sql(name="test_datetime", con=conn) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2955: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________________ test_datetime[postgresql_psycopg2_conn] ____________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2951: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________________ test_datetime_NaT[mysql_pymysql_engine] ____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_NaT(conn, request): 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame( 1749s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1749s ) 1749s df.loc[1, "A"] = np.nan 1749s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________________ test_datetime_NaT[mysql_pymysql_conn] _____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_NaT(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_datetime_NaT[postgresql_psycopg2_engine] _________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_NaT(conn, request): 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame( 1749s {"A": date_range("2013-01-01 09:00:00", periods=3), "B": np.arange(3.0)} 1749s ) 1749s df.loc[1, "A"] = np.nan 1749s > assert df.to_sql(name="test_datetime", con=conn, index=False) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2981: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________________ test_datetime_NaT[postgresql_psycopg2_conn] __________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_NaT(conn, request): 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:2976: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________________ test_datetime_date[mysql_pymysql_engine] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_date(conn, request): 1749s # test support for datetime.date 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 1749s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________________ test_datetime_date[mysql_pymysql_conn] ____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_date(conn, request): 1749s # test support for datetime.date 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_datetime_date[postgresql_psycopg2_engine] ________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_date(conn, request): 1749s # test support for datetime.date 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([date(2014, 1, 1), date(2014, 1, 2)], columns=["a"]) 1749s > assert df.to_sql(name="test_date", con=conn, index=False) == 2 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3002: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________________ test_datetime_date[postgresql_psycopg2_conn] _________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_date(conn, request): 1749s # test support for datetime.date 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3000: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ___________________ test_datetime_time[mysql_pymysql_engine] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s sqlite_buildin = 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_time(conn, request, sqlite_buildin): 1749s # test support for datetime.time 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 1749s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ____________________ test_datetime_time[mysql_pymysql_conn] ____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s sqlite_buildin = 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_time(conn, request, sqlite_buildin): 1749s # test support for datetime.time 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ________________ test_datetime_time[postgresql_psycopg2_engine] ________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s sqlite_buildin = 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_time(conn, request, sqlite_buildin): 1749s # test support for datetime.time 1749s conn_name = conn 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame([time(9, 0, 0), time(9, 1, 30)], columns=["a"]) 1749s > assert df.to_sql(name="test_time", con=conn, index=False) == 2 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3016: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s _________________ test_datetime_time[postgresql_psycopg2_conn] _________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s sqlite_buildin = 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_datetime_time(conn, request, sqlite_buildin): 1749s # test support for datetime.time 1749s conn_name = conn 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3014: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_mixed_dtype_insert[mysql_pymysql_engine] _________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_mixed_dtype_insert(conn, request): 1749s # see GH6509 1749s conn = request.getfixturevalue(conn) 1749s s1 = Series(2**25 + 1, dtype=np.int32) 1749s s2 = Series(0.0, dtype=np.float32) 1749s df = DataFrame({"s1": s1, "s2": s2}) 1749s 1749s # write and read again 1749s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_mixed_dtype_insert[mysql_pymysql_conn] __________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_mixed_dtype_insert(conn, request): 1749s # see GH6509 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________ test_mixed_dtype_insert[postgresql_psycopg2_engine] ______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_mixed_dtype_insert(conn, request): 1749s # see GH6509 1749s conn = request.getfixturevalue(conn) 1749s s1 = Series(2**25 + 1, dtype=np.int32) 1749s s2 = Series(0.0, dtype=np.float32) 1749s df = DataFrame({"s1": s1, "s2": s2}) 1749s 1749s # write and read again 1749s > assert df.to_sql(name="test_read_write", con=conn, index=False) == 1 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3046: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ______________ test_mixed_dtype_insert[postgresql_psycopg2_conn] _______________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_mixed_dtype_insert(conn, request): 1749s # see GH6509 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3040: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________________ test_nan_numeric[mysql_pymysql_engine] ____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_nan_numeric(conn, request): 1749s # NaNs in numeric float column 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 1749s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________________ test_nan_numeric[mysql_pymysql_conn] _____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_nan_numeric(conn, request): 1749s # NaNs in numeric float column 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_nan_numeric[postgresql_psycopg2_engine] _________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_nan_numeric(conn, request): 1749s # NaNs in numeric float column 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame({"A": [0, 1, 2], "B": [0.2, np.nan, 5.6]}) 1749s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3057: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________________ test_nan_numeric[postgresql_psycopg2_conn] __________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_nan_numeric(conn, request): 1749s # NaNs in numeric float column 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3055: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s __________________ test_nan_fullcolumn[mysql_pymysql_engine] ___________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_nan_fullcolumn(conn, request): 1749s # full NaN column (numeric float column) 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 1749s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s ___________________ test_nan_fullcolumn[mysql_pymysql_conn] ____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_nan_fullcolumn(conn, request): 1749s # full NaN column (numeric float column) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _______________ test_nan_fullcolumn[postgresql_psycopg2_engine] ________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_nan_fullcolumn(conn, request): 1749s # full NaN column (numeric float column) 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame({"A": [0, 1, 2], "B": [np.nan, np.nan, np.nan]}) 1749s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3073: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ________________ test_nan_fullcolumn[postgresql_psycopg2_conn] _________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'postgresql_psycopg2_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_nan_fullcolumn(conn, request): 1749s # full NaN column (numeric float column) 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3071: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1749s with postgresql_psycopg2_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1749s connection_factory = None, cursor_factory = None 1749s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1749s kwasync = {} 1749s 1749s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1749s """ 1749s Create a new database connection. 1749s 1749s The connection parameters can be specified as a string: 1749s 1749s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1749s 1749s or using a set of keyword arguments: 1749s 1749s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1749s 1749s Or as a mix of both. The basic connection parameters are: 1749s 1749s - *dbname*: the database name 1749s - *database*: the database name (only as keyword argument) 1749s - *user*: user name used to authenticate 1749s - *password*: password used to authenticate 1749s - *host*: database host address (defaults to UNIX socket if not provided) 1749s - *port*: connection port number (defaults to 5432 if not provided) 1749s 1749s Using the *connection_factory* parameter a different class or connections 1749s factory can be specified. It should be a callable object taking a dsn 1749s argument. 1749s 1749s Using the *cursor_factory* parameter, a new default cursor factory will be 1749s used by cursor(). 1749s 1749s Using *async*=True an asynchronous connection will be created. *async_* is 1749s a valid alias (for Python versions where ``async`` is a keyword). 1749s 1749s Any other keyword parameter will be passed to the underlying client 1749s library: the list of supported parameters depends on the library version. 1749s 1749s """ 1749s kwasync = {} 1749s if 'async' in kwargs: 1749s kwasync['async'] = kwargs.pop('async') 1749s if 'async_' in kwargs: 1749s kwasync['async_'] = kwargs.pop('async_') 1749s 1749s dsn = _ext.make_dsn(dsn, **kwargs) 1749s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1749s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1749s E Is the server running on that host and accepting TCP/IP connections? 1749s E 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1749s ____________________ test_nan_string[mysql_pymysql_engine] _____________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_nan_string(conn, request): 1749s # NaNs in string column 1749s conn = request.getfixturevalue(conn) 1749s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 1749s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1749s return func(*args, **kwargs) 1749s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1749s return sql.to_sql( 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1749s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1749s return SQLDatabase(con, schema, need_transaction) 1749s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1749s con = self.exit_stack.enter_context(con.connect()) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _____________________ test_nan_string[mysql_pymysql_conn] ______________________ 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s > sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3.13/socket.py:864: in create_connection 1749s raise exceptions[0] 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s address = ('localhost', 3306), timeout = 10, source_address = None 1749s 1749s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1749s source_address=None, *, all_errors=False): 1749s """Connect to *address* and return the socket object. 1749s 1749s Convenience function. Connect to *address* (a 2-tuple ``(host, 1749s port)``) and return the socket object. Passing the optional 1749s *timeout* parameter will set the timeout on the socket instance 1749s before attempting to connect. If no *timeout* is supplied, the 1749s global default timeout setting returned by :func:`getdefaulttimeout` 1749s is used. If *source_address* is set it must be a tuple of (host, port) 1749s for the socket to bind as a source address before making the connection. 1749s A host of '' or port 0 tells the OS to use the default. When a connection 1749s cannot be created, raises the last error if *all_errors* is False, 1749s and an ExceptionGroup of all errors if *all_errors* is True. 1749s """ 1749s 1749s host, port = address 1749s exceptions = [] 1749s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1749s af, socktype, proto, canonname, sa = res 1749s sock = None 1749s try: 1749s sock = socket(af, socktype, proto) 1749s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1749s sock.settimeout(timeout) 1749s if source_address: 1749s sock.bind(source_address) 1749s > sock.connect(sa) 1749s E ConnectionRefusedError: [Errno 111] Connection refused 1749s 1749s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1749s 1749s During handling of the above exception, another exception occurred: 1749s 1749s self = 1749s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1749s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s 1749s The above exception was the direct cause of the following exception: 1749s 1749s conn = 'mysql_pymysql_conn' 1749s request = > 1749s 1749s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1749s def test_nan_string(conn, request): 1749s # NaNs in string column 1749s > conn = request.getfixturevalue(conn) 1749s 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1749s fixturedef = self._get_active_fixturedef(argname) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1749s fixturedef.execute(request=subrequest) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1749s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1749s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1749s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1749s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1749s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1749s return (yield) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1749s result = call_fixture_func(fixturefunc, request, kwargs) 1749s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1749s fixture_result = next(generator) 1749s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1749s with mysql_pymysql_engine.connect() as conn: 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1749s return self._connection_cls(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1749s Connection._handle_dbapi_exception_noconnection( 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1749s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1749s self._dbapi_connection = engine.raw_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1749s return self._create_connection() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1749s return _ConnectionRecord(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1749s self.__connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1749s with util.safe_reraise(): 1749s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1749s raise exc_value.with_traceback(exc_tb) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1749s self.dbapi_connection = connection = pool._invoke_creator(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1749s return dialect.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1749s return self.loaded_dbapi.connect(*cargs, **cparams) 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1749s self.connect() 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s 1749s self = , sock = None 1749s 1749s def connect(self, sock=None): 1749s self._closed = False 1749s try: 1749s if sock is None: 1749s if self.unix_socket: 1749s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1749s sock.settimeout(self.connect_timeout) 1749s sock.connect(self.unix_socket) 1749s self.host_info = "Localhost via UNIX socket" 1749s self._secure = True 1749s if DEBUG: 1749s print("connected using unix_socket") 1749s else: 1749s kwargs = {} 1749s if self.bind_address is not None: 1749s kwargs["source_address"] = (self.bind_address, 0) 1749s while True: 1749s try: 1749s sock = socket.create_connection( 1749s (self.host, self.port), self.connect_timeout, **kwargs 1749s ) 1749s break 1749s except OSError as e: 1749s if e.errno == errno.EINTR: 1749s continue 1749s raise 1749s self.host_info = "socket %s:%d" % (self.host, self.port) 1749s if DEBUG: 1749s print("connected using socket") 1749s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1749s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1749s sock.settimeout(None) 1749s 1749s self._sock = sock 1749s self._rfile = sock.makefile("rb") 1749s self._next_seq_id = 0 1749s 1749s self._get_server_information() 1749s self._request_authentication() 1749s 1749s # Send "SET NAMES" query on init for: 1749s # - Ensure charaset (and collation) is set to the server. 1749s # - collation_id in handshake packet may be ignored. 1749s # - If collation is not specified, we don't know what is server's 1749s # default collation for the charset. For example, default collation 1749s # of utf8mb4 is: 1749s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1749s # - MySQL 8.0: utf8mb4_0900_ai_ci 1749s # 1749s # Reference: 1749s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1749s # - https://github.com/wagtail/wagtail/issues/9477 1749s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1749s self.set_character_set(self.charset, self.collation) 1749s 1749s if self.sql_mode is not None: 1749s c = self.cursor() 1749s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1749s c.close() 1749s 1749s if self.init_command is not None: 1749s c = self.cursor() 1749s c.execute(self.init_command) 1749s c.close() 1749s 1749s if self.autocommit_mode is not None: 1749s self.autocommit(self.autocommit_mode) 1749s except BaseException as e: 1749s self._rfile = None 1749s if sock is not None: 1749s try: 1749s sock.close() 1749s except: # noqa 1749s pass 1749s 1749s if isinstance(e, (OSError, IOError)): 1749s exc = err.OperationalError( 1749s CR.CR_CONN_HOST_ERROR, 1749s f"Can't connect to MySQL server on {self.host!r} ({e})", 1749s ) 1749s # Keep original exception and traceback to investigate error. 1749s exc.original_exception = e 1749s exc.traceback = traceback.format_exc() 1749s if DEBUG: 1749s print(exc.traceback) 1749s > raise exc 1749s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1749s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1749s 1749s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1749s _________________ test_nan_string[postgresql_psycopg2_engine] __________________ 1749s self = 1749s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1749s connection = None, _has_events = None, _allow_revalidate = True 1749s _allow_autobegin = True 1749s 1749s def __init__( 1749s self, 1749s engine: Engine, 1749s connection: Optional[PoolProxiedConnection] = None, 1749s _has_events: Optional[bool] = None, 1749s _allow_revalidate: bool = True, 1749s _allow_autobegin: bool = True, 1749s ): 1749s """Construct a new Connection.""" 1749s self.engine = engine 1749s self.dialect = dialect = engine.dialect 1749s 1749s if connection is None: 1749s try: 1749s > self._dbapi_connection = engine.raw_connection() 1749s 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1749s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1749s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1749s return self.pool.connect() 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1749s return _ConnectionFairy._checkout(self) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1749s fairy = _ConnectionRecord.checkout(pool) 1749s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1749s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_nan_string(conn, request): 1750s # NaNs in string column 1750s conn = request.getfixturevalue(conn) 1750s df = DataFrame({"A": [0, 1, 2], "B": ["a", "b", np.nan]}) 1750s > assert df.to_sql(name="test_nan", con=conn, index=False) == 3 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3091: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s __________________ test_nan_string[postgresql_psycopg2_conn] ___________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_nan_string(conn, request): 1750s # NaNs in string column 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3089: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _________________ test_to_sql_save_index[mysql_pymysql_engine] _________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_to_sql_save_index(conn, request): 1750s if "adbc" in conn: 1750s request.node.add_marker( 1750s pytest.mark.xfail( 1750s reason="ADBC implementation does not create index", strict=True 1750s ) 1750s ) 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s df = DataFrame.from_records( 1750s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 1750s ) 1750s 1750s tbl_name = "test_to_sql_saves_index" 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s __________________ test_to_sql_save_index[mysql_pymysql_conn] __________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_to_sql_save_index(conn, request): 1750s if "adbc" in conn: 1750s request.node.add_marker( 1750s pytest.mark.xfail( 1750s reason="ADBC implementation does not create index", strict=True 1750s ) 1750s ) 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ______________ test_to_sql_save_index[postgresql_psycopg2_engine] ______________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_to_sql_save_index(conn, request): 1750s if "adbc" in conn: 1750s request.node.add_marker( 1750s pytest.mark.xfail( 1750s reason="ADBC implementation does not create index", strict=True 1750s ) 1750s ) 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s df = DataFrame.from_records( 1750s [(1, 2.1, "line1"), (2, 1.5, "line2")], columns=["A", "B", "C"], index=["A"] 1750s ) 1750s 1750s tbl_name = "test_to_sql_saves_index" 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3120: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _______________ test_to_sql_save_index[postgresql_psycopg2_conn] _______________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_to_sql_save_index(conn, request): 1750s if "adbc" in conn: 1750s request.node.add_marker( 1750s pytest.mark.xfail( 1750s reason="ADBC implementation does not create index", strict=True 1750s ) 1750s ) 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3114: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ___________________ test_transactions[mysql_pymysql_engine] ____________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_transactions(conn, request): 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s 1750s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 1750s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 1750s from sqlalchemy import text 1750s 1750s stmt = text(stmt) 1750s 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ____________________ test_transactions[mysql_pymysql_conn] _____________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_transactions(conn, request): 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ________________ test_transactions[postgresql_psycopg2_engine] _________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_transactions(conn, request): 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s 1750s stmt = "CREATE TABLE test_trans (A INT, B TEXT)" 1750s if conn_name != "sqlite_buildin" and "adbc" not in conn_name: 1750s from sqlalchemy import text 1750s 1750s stmt = text(stmt) 1750s 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3156: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _________________ test_transactions[postgresql_psycopg2_conn] __________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_transactions(conn, request): 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3148: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _______________ test_transaction_rollback[mysql_pymysql_engine] ________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_transaction_rollback(conn, request): 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ________________ test_transaction_rollback[mysql_pymysql_conn] _________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_transaction_rollback(conn, request): 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ____________ test_transaction_rollback[postgresql_psycopg2_engine] _____________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_transaction_rollback(conn, request): 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3165: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _____________ test_transaction_rollback[postgresql_psycopg2_conn] ______________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_transaction_rollback(conn, request): 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3164: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ______________ test_get_schema_create_table[mysql_pymysql_engine] ______________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s test_frame3 = index A B 1750s 0 2000-01-03 00:00:00 2147483647 -1.987670 1750s 1 2000-01-04 00:00:00 -29 -0.041232 1750s 2 2000-01-05 00:00:00 20000 0.731168 1750s 3 2000-01-06 00:00:00 -290867 1.567621 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_get_schema_create_table(conn, request, test_frame3): 1750s # Use a dataframe without a bool column, since MySQL converts bool to 1750s # TINYINT (which read_sql_table returns as an int and causes a dtype 1750s # mismatch) 1750s if conn == "sqlite_str": 1750s request.applymarker( 1750s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1750s ) 1750s 1750s conn = request.getfixturevalue(conn) 1750s 1750s from sqlalchemy import text 1750s from sqlalchemy.engine import Engine 1750s 1750s tbl = "test_get_schema_create_table" 1750s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1750s with pandasSQL_builder(con=con) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _______________ test_get_schema_create_table[mysql_pymysql_conn] _______________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s test_frame3 = index A B 1750s 0 2000-01-03 00:00:00 2147483647 -1.987670 1750s 1 2000-01-04 00:00:00 -29 -0.041232 1750s 2 2000-01-05 00:00:00 20000 0.731168 1750s 3 2000-01-06 00:00:00 -290867 1.567621 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_get_schema_create_table(conn, request, test_frame3): 1750s # Use a dataframe without a bool column, since MySQL converts bool to 1750s # TINYINT (which read_sql_table returns as an int and causes a dtype 1750s # mismatch) 1750s if conn == "sqlite_str": 1750s request.applymarker( 1750s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1750s ) 1750s 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ___________ test_get_schema_create_table[postgresql_psycopg2_engine] ___________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s test_frame3 = index A B 1750s 0 2000-01-03 00:00:00 2147483647 -1.987670 1750s 1 2000-01-04 00:00:00 -29 -0.041232 1750s 2 2000-01-05 00:00:00 20000 0.731168 1750s 3 2000-01-06 00:00:00 -290867 1.567621 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_get_schema_create_table(conn, request, test_frame3): 1750s # Use a dataframe without a bool column, since MySQL converts bool to 1750s # TINYINT (which read_sql_table returns as an int and causes a dtype 1750s # mismatch) 1750s if conn == "sqlite_str": 1750s request.applymarker( 1750s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1750s ) 1750s 1750s conn = request.getfixturevalue(conn) 1750s 1750s from sqlalchemy import text 1750s from sqlalchemy.engine import Engine 1750s 1750s tbl = "test_get_schema_create_table" 1750s > create_sql = sql.get_schema(test_frame3, tbl, con=conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3219: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:2923: in get_schema 1750s with pandasSQL_builder(con=con) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ____________ test_get_schema_create_table[postgresql_psycopg2_conn] ____________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s test_frame3 = index A B 1750s 0 2000-01-03 00:00:00 2147483647 -1.987670 1750s 1 2000-01-04 00:00:00 -29 -0.041232 1750s 2 2000-01-05 00:00:00 20000 0.731168 1750s 3 2000-01-06 00:00:00 -290867 1.567621 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_get_schema_create_table(conn, request, test_frame3): 1750s # Use a dataframe without a bool column, since MySQL converts bool to 1750s # TINYINT (which read_sql_table returns as an int and causes a dtype 1750s # mismatch) 1750s if conn == "sqlite_str": 1750s request.applymarker( 1750s pytest.mark.xfail(reason="test does not support sqlite_str fixture") 1750s ) 1750s 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3213: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _______________________ test_dtype[mysql_pymysql_engine] _______________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_dtype(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s conn = request.getfixturevalue(conn) 1750s 1750s from sqlalchemy import ( 1750s TEXT, 1750s String, 1750s ) 1750s from sqlalchemy.schema import MetaData 1750s 1750s cols = ["A", "B"] 1750s data = [(0.8, True), (0.9, None)] 1750s df = DataFrame(data, columns=cols) 1750s > assert df.to_sql(name="dtype_test", con=conn) == 2 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ________________________ test_dtype[mysql_pymysql_conn] ________________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_dtype(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ____________________ test_dtype[postgresql_psycopg2_engine] ____________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_dtype(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s conn = request.getfixturevalue(conn) 1750s 1750s from sqlalchemy import ( 1750s TEXT, 1750s String, 1750s ) 1750s from sqlalchemy.schema import MetaData 1750s 1750s cols = ["A", "B"] 1750s data = [(0.8, True), (0.9, None)] 1750s df = DataFrame(data, columns=cols) 1750s > assert df.to_sql(name="dtype_test", con=conn) == 2 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3249: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _____________________ test_dtype[postgresql_psycopg2_conn] _____________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_dtype(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3238: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ____________________ test_notna_dtype[mysql_pymysql_engine] ____________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_notna_dtype(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s 1750s from sqlalchemy import ( 1750s Boolean, 1750s DateTime, 1750s Float, 1750s Integer, 1750s ) 1750s from sqlalchemy.schema import MetaData 1750s 1750s cols = { 1750s "Bool": Series([True, None]), 1750s "Date": Series([datetime(2012, 5, 1), None]), 1750s "Int": Series([1, None], dtype="object"), 1750s "Float": Series([1.1, None]), 1750s } 1750s df = DataFrame(cols) 1750s 1750s tbl = "notna_dtype_test" 1750s > assert df.to_sql(name=tbl, con=conn) == 2 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _____________________ test_notna_dtype[mysql_pymysql_conn] _____________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_notna_dtype(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _________________ test_notna_dtype[postgresql_psycopg2_engine] _________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_notna_dtype(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s 1750s from sqlalchemy import ( 1750s Boolean, 1750s DateTime, 1750s Float, 1750s Integer, 1750s ) 1750s from sqlalchemy.schema import MetaData 1750s 1750s cols = { 1750s "Bool": Series([True, None]), 1750s "Date": Series([datetime(2012, 5, 1), None]), 1750s "Int": Series([1, None], dtype="object"), 1750s "Float": Series([1.1, None]), 1750s } 1750s df = DataFrame(cols) 1750s 1750s tbl = "notna_dtype_test" 1750s > assert df.to_sql(name=tbl, con=conn) == 2 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3300: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s __________________ test_notna_dtype[postgresql_psycopg2_conn] __________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_notna_dtype(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3281: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _________________ test_double_precision[mysql_pymysql_engine] __________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_double_precision(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s conn = request.getfixturevalue(conn) 1750s 1750s from sqlalchemy import ( 1750s BigInteger, 1750s Float, 1750s Integer, 1750s ) 1750s from sqlalchemy.schema import MetaData 1750s 1750s V = 1.23456789101112131415 1750s 1750s df = DataFrame( 1750s { 1750s "f32": Series([V], dtype="float32"), 1750s "f64": Series([V], dtype="float64"), 1750s "f64_as_f32": Series([V], dtype="float64"), 1750s "i32": Series([5], dtype="int32"), 1750s "i64": Series([5], dtype="int64"), 1750s } 1750s ) 1750s 1750s assert ( 1750s > df.to_sql( 1750s name="test_dtypes", 1750s con=conn, 1750s index=False, 1750s if_exists="replace", 1750s dtype={"f64_as_f32": Float(precision=23)}, 1750s ) 1750s == 1 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s __________________ test_double_precision[mysql_pymysql_conn] ___________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_double_precision(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ______________ test_double_precision[postgresql_psycopg2_engine] _______________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_double_precision(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s conn = request.getfixturevalue(conn) 1750s 1750s from sqlalchemy import ( 1750s BigInteger, 1750s Float, 1750s Integer, 1750s ) 1750s from sqlalchemy.schema import MetaData 1750s 1750s V = 1.23456789101112131415 1750s 1750s df = DataFrame( 1750s { 1750s "f32": Series([V], dtype="float32"), 1750s "f64": Series([V], dtype="float64"), 1750s "f64_as_f32": Series([V], dtype="float64"), 1750s "i32": Series([5], dtype="int32"), 1750s "i64": Series([5], dtype="int64"), 1750s } 1750s ) 1750s 1750s assert ( 1750s > df.to_sql( 1750s name="test_dtypes", 1750s con=conn, 1750s index=False, 1750s if_exists="replace", 1750s dtype={"f64_as_f32": Float(precision=23)}, 1750s ) 1750s == 1 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3339: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _______________ test_double_precision[postgresql_psycopg2_conn] ________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_double_precision(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("sqlite_str has no inspection system") 1750s 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3317: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _____________ test_connectable_issue_example[mysql_pymysql_engine] _____________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_connectable_issue_example(conn, request): 1750s conn = request.getfixturevalue(conn) 1750s 1750s # This tests the example raised in issue 1750s # https://github.com/pandas-dev/pandas/issues/10104 1750s from sqlalchemy.engine import Engine 1750s 1750s def test_select(connection): 1750s query = "SELECT test_foo_data FROM test_foo_data" 1750s return sql.read_sql_query(query, con=connection) 1750s 1750s def test_append(connection, data): 1750s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 1750s 1750s def test_connectable(conn): 1750s # https://github.com/sqlalchemy/sqlalchemy/commit/ 1750s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 1750s foo_data = test_select(conn) 1750s test_append(conn, foo_data) 1750s 1750s def main(connectable): 1750s if isinstance(connectable, Engine): 1750s with connectable.connect() as conn: 1750s with conn.begin(): 1750s test_connectable(conn) 1750s else: 1750s test_connectable(connectable) 1750s 1750s assert ( 1750s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 1750s == 3 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ______________ test_connectable_issue_example[mysql_pymysql_conn] ______________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_connectable_issue_example(conn, request): 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s __________ test_connectable_issue_example[postgresql_psycopg2_engine] __________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_connectable_issue_example(conn, request): 1750s conn = request.getfixturevalue(conn) 1750s 1750s # This tests the example raised in issue 1750s # https://github.com/pandas-dev/pandas/issues/10104 1750s from sqlalchemy.engine import Engine 1750s 1750s def test_select(connection): 1750s query = "SELECT test_foo_data FROM test_foo_data" 1750s return sql.read_sql_query(query, con=connection) 1750s 1750s def test_append(connection, data): 1750s data.to_sql(name="test_foo_data", con=connection, if_exists="append") 1750s 1750s def test_connectable(conn): 1750s # https://github.com/sqlalchemy/sqlalchemy/commit/ 1750s # 00b5c10846e800304caa86549ab9da373b42fa5d#r48323973 1750s foo_data = test_select(conn) 1750s test_append(conn, foo_data) 1750s 1750s def main(connectable): 1750s if isinstance(connectable, Engine): 1750s with connectable.connect() as conn: 1750s with conn.begin(): 1750s test_connectable(conn) 1750s else: 1750s test_connectable(connectable) 1750s 1750s assert ( 1750s > DataFrame({"test_foo_data": [0, 1, 2]}).to_sql(name="test_foo_data", con=conn) 1750s == 3 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3394: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ___________ test_connectable_issue_example[postgresql_psycopg2_conn] ___________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_connectable_issue_example(conn, request): 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3366: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] _________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s input = {'foo': [inf]} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s 1750s if "mysql" in conn_name: 1750s # GH 36465 1750s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1750s # for pymysql version >= 0.10 1750s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1750s pymysql = td.versioned_importorskip("pymysql") 1750s 1750s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1750s mark = pytest.mark.xfail(reason="GH 36465") 1750s request.applymarker(mark) 1750s 1750s msg = "inf cannot be used with MySQL" 1750s with pytest.raises(ValueError, match=msg): 1750s > df.to_sql(name="foobar", con=conn, index=False) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s __________ test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] __________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s input = {'foo': [inf]} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] ______ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s input = {'foo': [inf]} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s 1750s if "mysql" in conn_name: 1750s # GH 36465 1750s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1750s # for pymysql version >= 0.10 1750s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1750s pymysql = td.versioned_importorskip("pymysql") 1750s 1750s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1750s mark = pytest.mark.xfail(reason="GH 36465") 1750s request.applymarker(mark) 1750s 1750s msg = "inf cannot be used with MySQL" 1750s with pytest.raises(ValueError, match=msg): 1750s df.to_sql(name="foobar", con=conn, index=False) 1750s else: 1750s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _______ test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] _______ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s input = {'foo': [inf]} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] _________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s input = {'foo': [-inf]} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s 1750s if "mysql" in conn_name: 1750s # GH 36465 1750s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1750s # for pymysql version >= 0.10 1750s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1750s pymysql = td.versioned_importorskip("pymysql") 1750s 1750s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1750s mark = pytest.mark.xfail(reason="GH 36465") 1750s request.applymarker(mark) 1750s 1750s msg = "inf cannot be used with MySQL" 1750s with pytest.raises(ValueError, match=msg): 1750s > df.to_sql(name="foobar", con=conn, index=False) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s __________ test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] __________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s input = {'foo': [-inf]} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] ______ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s input = {'foo': [-inf]} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s 1750s if "mysql" in conn_name: 1750s # GH 36465 1750s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1750s # for pymysql version >= 0.10 1750s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1750s pymysql = td.versioned_importorskip("pymysql") 1750s 1750s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1750s mark = pytest.mark.xfail(reason="GH 36465") 1750s request.applymarker(mark) 1750s 1750s msg = "inf cannot be used with MySQL" 1750s with pytest.raises(ValueError, match=msg): 1750s df.to_sql(name="foobar", con=conn, index=False) 1750s else: 1750s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _______ test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] _______ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s input = {'foo': [-inf]} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] _________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s input = {'foo': [-inf], 'infe0': ['bar']} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s 1750s if "mysql" in conn_name: 1750s # GH 36465 1750s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1750s # for pymysql version >= 0.10 1750s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1750s pymysql = td.versioned_importorskip("pymysql") 1750s 1750s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1750s mark = pytest.mark.xfail(reason="GH 36465") 1750s request.applymarker(mark) 1750s 1750s msg = "inf cannot be used with MySQL" 1750s with pytest.raises(ValueError, match=msg): 1750s > df.to_sql(name="foobar", con=conn, index=False) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3425: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s __________ test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] __________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s input = {'foo': [-inf], 'infe0': ['bar']} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] ______ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s input = {'foo': [-inf], 'infe0': ['bar']} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s 1750s if "mysql" in conn_name: 1750s # GH 36465 1750s # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error 1750s # for pymysql version >= 0.10 1750s # TODO(GH#36465): remove this version check after GH 36465 is fixed 1750s pymysql = td.versioned_importorskip("pymysql") 1750s 1750s if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns: 1750s mark = pytest.mark.xfail(reason="GH 36465") 1750s request.applymarker(mark) 1750s 1750s msg = "inf cannot be used with MySQL" 1750s with pytest.raises(ValueError, match=msg): 1750s df.to_sql(name="foobar", con=conn, index=False) 1750s else: 1750s > assert df.to_sql(name="foobar", con=conn, index=False) == 1 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3427: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _______ test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] _______ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s input = {'foo': [-inf], 'infe0': ['bar']} 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s @pytest.mark.parametrize( 1750s "input", 1750s [{"foo": [np.inf]}, {"foo": [-np.inf]}, {"foo": [-np.inf], "infe0": ["bar"]}], 1750s ) 1750s def test_to_sql_with_negative_npinf(conn, request, input): 1750s # GH 34431 1750s 1750s df = DataFrame(input) 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3410: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s __________________ test_temporary_table[mysql_pymysql_engine] __________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_temporary_table(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("test does not work with str connection") 1750s 1750s conn = request.getfixturevalue(conn) 1750s 1750s from sqlalchemy import ( 1750s Column, 1750s Integer, 1750s Unicode, 1750s select, 1750s ) 1750s from sqlalchemy.orm import ( 1750s Session, 1750s declarative_base, 1750s ) 1750s 1750s test_data = "Hello, World!" 1750s expected = DataFrame({"spam": [test_data]}) 1750s Base = declarative_base() 1750s 1750s class Temporary(Base): 1750s __tablename__ = "temp_test" 1750s __table_args__ = {"prefixes": ["TEMPORARY"]} 1750s id = Column(Integer, primary_key=True) 1750s spam = Column(Unicode(30), nullable=False) 1750s 1750s with Session(conn) as session: 1750s with session.begin(): 1750s > conn = session.connection() 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 1750s return self._connection_for_bind( 1750s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 1750s return trans._connection_for_bind(engine, execution_options) 1750s :2: in _connection_for_bind 1750s ??? 1750s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 1750s ret_value = fn(self, *arg, **kw) 1750s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 1750s conn = bind.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ___________________ test_temporary_table[mysql_pymysql_conn] ___________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_temporary_table(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("test does not work with str connection") 1750s 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _______________ test_temporary_table[postgresql_psycopg2_engine] _______________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_temporary_table(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("test does not work with str connection") 1750s 1750s conn = request.getfixturevalue(conn) 1750s 1750s from sqlalchemy import ( 1750s Column, 1750s Integer, 1750s Unicode, 1750s select, 1750s ) 1750s from sqlalchemy.orm import ( 1750s Session, 1750s declarative_base, 1750s ) 1750s 1750s test_data = "Hello, World!" 1750s expected = DataFrame({"spam": [test_data]}) 1750s Base = declarative_base() 1750s 1750s class Temporary(Base): 1750s __tablename__ = "temp_test" 1750s __table_args__ = {"prefixes": ["TEMPORARY"]} 1750s id = Column(Integer, primary_key=True) 1750s spam = Column(Unicode(30), nullable=False) 1750s 1750s with Session(conn) as session: 1750s with session.begin(): 1750s > conn = session.connection() 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3462: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2094: in connection 1750s return self._connection_for_bind( 1750s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:2110: in _connection_for_bind 1750s return trans._connection_for_bind(engine, execution_options) 1750s :2: in _connection_for_bind 1750s ??? 1750s /usr/lib/python3/dist-packages/sqlalchemy/orm/state_changes.py:139: in _go 1750s ret_value = fn(self, *arg, **kw) 1750s /usr/lib/python3/dist-packages/sqlalchemy/orm/session.py:1189: in _connection_for_bind 1750s conn = bind.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ________________ test_temporary_table[postgresql_psycopg2_conn] ________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_temporary_table(conn, request): 1750s if conn == "sqlite_str": 1750s pytest.skip("test does not work with str connection") 1750s 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3437: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s __________________ test_invalid_engine[mysql_pymysql_engine] ___________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_invalid_engine(conn, request, test_frame1): 1750s if conn == "sqlite_buildin" or "adbc" in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1750s ) 1750s ) 1750s 1750s conn = request.getfixturevalue(conn) 1750s msg = "engine must be one of 'auto', 'sqlalchemy'" 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ___________________ test_invalid_engine[mysql_pymysql_conn] ____________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_invalid_engine(conn, request, test_frame1): 1750s if conn == "sqlite_buildin" or "adbc" in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1750s ) 1750s ) 1750s 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _______________ test_invalid_engine[postgresql_psycopg2_engine] ________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_invalid_engine(conn, request, test_frame1): 1750s if conn == "sqlite_buildin" or "adbc" in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1750s ) 1750s ) 1750s 1750s conn = request.getfixturevalue(conn) 1750s msg = "engine must be one of 'auto', 'sqlalchemy'" 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3481: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ________________ test_invalid_engine[postgresql_psycopg2_conn] _________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_invalid_engine(conn, request, test_frame1): 1750s if conn == "sqlite_buildin" or "adbc" in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason="SQLiteDatabase/ADBCDatabase does not raise for bad engine" 1750s ) 1750s ) 1750s 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3479: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ______________ test_to_sql_with_sql_engine[mysql_pymysql_engine] _______________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1750s """`to_sql` with the `engine` param""" 1750s # mostly copied from this class's `_to_sql()` method 1750s conn = request.getfixturevalue(conn) 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _______________ test_to_sql_with_sql_engine[mysql_pymysql_conn] ________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1750s """`to_sql` with the `engine` param""" 1750s # mostly copied from this class's `_to_sql()` method 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ___________ test_to_sql_with_sql_engine[postgresql_psycopg2_engine] ____________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1750s """`to_sql` with the `engine` param""" 1750s # mostly copied from this class's `_to_sql()` method 1750s conn = request.getfixturevalue(conn) 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3491: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ____________ test_to_sql_with_sql_engine[postgresql_psycopg2_conn] _____________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_to_sql_with_sql_engine(conn, request, test_frame1): 1750s """`to_sql` with the `engine` param""" 1750s # mostly copied from this class's `_to_sql()` method 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3490: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ________________ test_options_sqlalchemy[mysql_pymysql_engine] _________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_options_sqlalchemy(conn, request, test_frame1): 1750s # use the set option 1750s conn = request.getfixturevalue(conn) 1750s with pd.option_context("io.sql.engine", "sqlalchemy"): 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _________________ test_options_sqlalchemy[mysql_pymysql_conn] __________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_options_sqlalchemy(conn, request, test_frame1): 1750s # use the set option 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _____________ test_options_sqlalchemy[postgresql_psycopg2_engine] ______________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_options_sqlalchemy(conn, request, test_frame1): 1750s # use the set option 1750s conn = request.getfixturevalue(conn) 1750s with pd.option_context("io.sql.engine", "sqlalchemy"): 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3506: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ______________ test_options_sqlalchemy[postgresql_psycopg2_conn] _______________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", sqlalchemy_connectable) 1750s def test_options_sqlalchemy(conn, request, test_frame1): 1750s # use the set option 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3504: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ___________________ test_options_auto[mysql_pymysql_engine] ____________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_options_auto(conn, request, test_frame1): 1750s # use the set option 1750s conn = request.getfixturevalue(conn) 1750s with pd.option_context("io.sql.engine", "auto"): 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ____________________ test_options_auto[mysql_pymysql_conn] _____________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_options_auto(conn, request, test_frame1): 1750s # use the set option 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ________________ test_options_auto[postgresql_psycopg2_engine] _________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_options_auto(conn, request, test_frame1): 1750s # use the set option 1750s conn = request.getfixturevalue(conn) 1750s with pd.option_context("io.sql.engine", "auto"): 1750s > with pandasSQL_builder(conn) as pandasSQL: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3521: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _________________ test_options_auto[postgresql_psycopg2_conn] __________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s test_frame1 = index A B C D 1750s 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 1750s 3 2000-01-06 00:00:00 1.120202 1.567621 0.003641 0.675253 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_options_auto(conn, request, test_frame1): 1750s # use the set option 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3519: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83740> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype_backend( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s # GH#50048 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83740> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype_backend( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s # GH#50048 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83740> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype_backend( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s # GH#50048 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83740> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype_backend( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s # GH#50048 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_engine] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s string_storage = 'python', func = 'read_sql_query' 1750s dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83880> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype_backend( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s # GH#50048 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-mysql_pymysql_conn] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s string_storage = 'python', func = 'read_sql_query' 1750s dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83880> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype_backend( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s # GH#50048 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_engine] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s string_storage = 'python', func = 'read_sql_query' 1750s dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83920> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype_backend( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s # GH#50048 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3567: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype_backend[python-numpy_nullable-read_sql_query-postgresql_psycopg2_conn] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s string_storage = 'python', func = 'read_sql_query' 1750s dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a839c0> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype_backend( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s # GH#50048 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3564: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_engine] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83c40> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1750s def test_read_sql_dtype_backend_table( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s if "sqlite" in conn and "adbc" not in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason=( 1750s "SQLite actually returns proper boolean values via " 1750s "read_sql_table, but before pytest refactor was skipped" 1750s ) 1750s ) 1750s ) 1750s # GH#50048 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-mysql_pymysql_conn] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83c40> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1750s def test_read_sql_dtype_backend_table( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s if "sqlite" in conn and "adbc" not in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason=( 1750s "SQLite actually returns proper boolean values via " 1750s "read_sql_table, but before pytest refactor was skipped" 1750s ) 1750s ) 1750s ) 1750s # GH#50048 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_engine] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83ce0> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1750s def test_read_sql_dtype_backend_table( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s if "sqlite" in conn and "adbc" not in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason=( 1750s "SQLite actually returns proper boolean values via " 1750s "read_sql_table, but before pytest refactor was skipped" 1750s ) 1750s ) 1750s ) 1750s # GH#50048 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql-postgresql_psycopg2_conn] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s string_storage = 'python', func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88a83d80> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1750s def test_read_sql_dtype_backend_table( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s if "sqlite" in conn and "adbc" not in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason=( 1750s "SQLite actually returns proper boolean values via " 1750s "read_sql_table, but before pytest refactor was skipped" 1750s ) 1750s ) 1750s ) 1750s # GH#50048 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_engine] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s string_storage = 'python', func = 'read_sql_table' 1750s dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88c58220> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1750s def test_read_sql_dtype_backend_table( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s if "sqlite" in conn and "adbc" not in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason=( 1750s "SQLite actually returns proper boolean values via " 1750s "read_sql_table, but before pytest refactor was skipped" 1750s ) 1750s ) 1750s ) 1750s # GH#50048 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-mysql_pymysql_conn] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s string_storage = 'python', func = 'read_sql_table' 1750s dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88c582c0> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1750s def test_read_sql_dtype_backend_table( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s if "sqlite" in conn and "adbc" not in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason=( 1750s "SQLite actually returns proper boolean values via " 1750s "read_sql_table, but before pytest refactor was skipped" 1750s ) 1750s ) 1750s ) 1750s # GH#50048 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_engine] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s string_storage = 'python', func = 'read_sql_table' 1750s dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88c58360> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1750s def test_read_sql_dtype_backend_table( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s if "sqlite" in conn and "adbc" not in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason=( 1750s "SQLite actually returns proper boolean values via " 1750s "read_sql_table, but before pytest refactor was skipped" 1750s ) 1750s ) 1750s ) 1750s # GH#50048 1750s conn_name = conn 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3619: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype_backend_table[python-numpy_nullable-read_sql_table-postgresql_psycopg2_conn] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s string_storage = 'python', func = 'read_sql_table' 1750s dtype_backend = 'numpy_nullable' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s dtype_backend_expected = .func at 0x77ff88c58400> 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table"]) 1750s def test_read_sql_dtype_backend_table( 1750s conn, 1750s request, 1750s string_storage, 1750s func, 1750s dtype_backend, 1750s dtype_backend_data, 1750s dtype_backend_expected, 1750s ): 1750s if "sqlite" in conn and "adbc" not in conn: 1750s request.applymarker( 1750s pytest.mark.xfail( 1750s reason=( 1750s "SQLite actually returns proper boolean values via " 1750s "read_sql_table, but before pytest refactor was skipped" 1750s ) 1750s ) 1750s ) 1750s # GH#50048 1750s conn_name = conn 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3616: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ___ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] ___ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s func = 'read_sql' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ____ test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] ____ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s func = 'read_sql' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s func = 'read_sql' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s func = 'read_sql' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_engine] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s func = 'read_sql_table' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-mysql_pymysql_conn] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s func = 'read_sql_table' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_engine] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s func = 'read_sql_table' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_invalid_dtype_backend_table[read_sql_table-postgresql_psycopg2_conn] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s func = 'read_sql_table' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_engine] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s func = 'read_sql_query' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-mysql_pymysql_conn] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s func = 'read_sql_query' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_engine] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s func = 'read_sql_query' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = dtype_backend_data 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3648: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_invalid_dtype_backend_table[read_sql_query-postgresql_psycopg2_conn] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s func = 'read_sql_query' 1750s dtype_backend_data = a b c d e f g h 1750s 0 1 1 1.5 1.5 True True a a 1750s 1 2 2.0 False False b b 1750s 2 3 3 2.5 2.5 None True c None 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_table", "read_sql_query"]) 1750s def test_read_sql_invalid_dtype_backend_table(conn, request, func, dtype_backend_data): 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3645: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ______________ test_chunksize_empty_dtypes[mysql_pymysql_engine] _______________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_chunksize_empty_dtypes(conn, request): 1750s # GH#50245 1750s if "adbc" in conn: 1750s request.node.add_marker( 1750s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1750s ) 1750s conn = request.getfixturevalue(conn) 1750s dtypes = {"a": "int64", "b": "object"} 1750s df = DataFrame(columns=["a", "b"]).astype(dtypes) 1750s expected = df.copy() 1750s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _______________ test_chunksize_empty_dtypes[mysql_pymysql_conn] ________________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_chunksize_empty_dtypes(conn, request): 1750s # GH#50245 1750s if "adbc" in conn: 1750s request.node.add_marker( 1750s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1750s ) 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ___________ test_chunksize_empty_dtypes[postgresql_psycopg2_engine] ____________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_chunksize_empty_dtypes(conn, request): 1750s # GH#50245 1750s if "adbc" in conn: 1750s request.node.add_marker( 1750s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1750s ) 1750s conn = request.getfixturevalue(conn) 1750s dtypes = {"a": "int64", "b": "object"} 1750s df = DataFrame(columns=["a", "b"]).astype(dtypes) 1750s expected = df.copy() 1750s > df.to_sql(name="test", con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3741: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ____________ test_chunksize_empty_dtypes[postgresql_psycopg2_conn] _____________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s def test_chunksize_empty_dtypes(conn, request): 1750s # GH#50245 1750s if "adbc" in conn: 1750s request.node.add_marker( 1750s pytest.mark.xfail(reason="chunksize argument NotImplemented with ADBC") 1750s ) 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3737: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ___ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] ___ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s func = 'read_sql', dtype_backend = 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ____ test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] ____ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s func = 'read_sql', dtype_backend = 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s func = 'read_sql', dtype_backend = 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s func = 'read_sql', dtype_backend = 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] _______ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _______ test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] ________ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ___ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] ____ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ____ test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] _____ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s func = 'read_sql', dtype_backend = 'numpy_nullable' 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_engine] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s func = 'read_sql_query', dtype_backend = 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-mysql_pymysql_conn] _ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s func = 'read_sql_query', dtype_backend = 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_engine] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s func = 'read_sql_query', dtype_backend = 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype[read_sql_query-_NoDefault.no_default-postgresql_psycopg2_conn] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s func = 'read_sql_query', dtype_backend = 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s ___ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] ____ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(mysql+pymysql://root@localhost:3306/pandas) 1750s request = > 1750s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s ____ test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] _____ 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s > sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:649: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3.13/socket.py:864: in create_connection 1750s raise exceptions[0] 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s address = ('localhost', 3306), timeout = 10, source_address = None 1750s 1750s def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT, 1750s source_address=None, *, all_errors=False): 1750s """Connect to *address* and return the socket object. 1750s 1750s Convenience function. Connect to *address* (a 2-tuple ``(host, 1750s port)``) and return the socket object. Passing the optional 1750s *timeout* parameter will set the timeout on the socket instance 1750s before attempting to connect. If no *timeout* is supplied, the 1750s global default timeout setting returned by :func:`getdefaulttimeout` 1750s is used. If *source_address* is set it must be a tuple of (host, port) 1750s for the socket to bind as a source address before making the connection. 1750s A host of '' or port 0 tells the OS to use the default. When a connection 1750s cannot be created, raises the last error if *all_errors* is False, 1750s and an ExceptionGroup of all errors if *all_errors* is True. 1750s """ 1750s 1750s host, port = address 1750s exceptions = [] 1750s for res in getaddrinfo(host, port, 0, SOCK_STREAM): 1750s af, socktype, proto, canonname, sa = res 1750s sock = None 1750s try: 1750s sock = socket(af, socktype, proto) 1750s if timeout is not _GLOBAL_DEFAULT_TIMEOUT: 1750s sock.settimeout(timeout) 1750s if source_address: 1750s sock.bind(source_address) 1750s > sock.connect(sa) 1750s E ConnectionRefusedError: [Errno 111] Connection refused 1750s 1750s /usr/lib/python3.13/socket.py:849: ConnectionRefusedError 1750s 1750s During handling of the above exception, another exception occurred: 1750s 1750s self = 1750s engine = Engine(mysql+pymysql://root@localhost:3306/pandas), connection = None 1750s _has_events = None, _allow_revalidate = True, _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'mysql_pymysql_conn' 1750s request = > 1750s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:634: in mysql_pymysql_conn 1750s with mysql_pymysql_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:361: in __init__ 1750s self.connect() 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s self = , sock = None 1750s 1750s def connect(self, sock=None): 1750s self._closed = False 1750s try: 1750s if sock is None: 1750s if self.unix_socket: 1750s sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 1750s sock.settimeout(self.connect_timeout) 1750s sock.connect(self.unix_socket) 1750s self.host_info = "Localhost via UNIX socket" 1750s self._secure = True 1750s if DEBUG: 1750s print("connected using unix_socket") 1750s else: 1750s kwargs = {} 1750s if self.bind_address is not None: 1750s kwargs["source_address"] = (self.bind_address, 0) 1750s while True: 1750s try: 1750s sock = socket.create_connection( 1750s (self.host, self.port), self.connect_timeout, **kwargs 1750s ) 1750s break 1750s except OSError as e: 1750s if e.errno == errno.EINTR: 1750s continue 1750s raise 1750s self.host_info = "socket %s:%d" % (self.host, self.port) 1750s if DEBUG: 1750s print("connected using socket") 1750s sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 1750s sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) 1750s sock.settimeout(None) 1750s 1750s self._sock = sock 1750s self._rfile = sock.makefile("rb") 1750s self._next_seq_id = 0 1750s 1750s self._get_server_information() 1750s self._request_authentication() 1750s 1750s # Send "SET NAMES" query on init for: 1750s # - Ensure charaset (and collation) is set to the server. 1750s # - collation_id in handshake packet may be ignored. 1750s # - If collation is not specified, we don't know what is server's 1750s # default collation for the charset. For example, default collation 1750s # of utf8mb4 is: 1750s # - MySQL 5.7, MariaDB 10.x: utf8mb4_general_ci 1750s # - MySQL 8.0: utf8mb4_0900_ai_ci 1750s # 1750s # Reference: 1750s # - https://github.com/PyMySQL/PyMySQL/issues/1092 1750s # - https://github.com/wagtail/wagtail/issues/9477 1750s # - https://zenn.dev/methane/articles/2023-mysql-collation (Japanese) 1750s self.set_character_set(self.charset, self.collation) 1750s 1750s if self.sql_mode is not None: 1750s c = self.cursor() 1750s c.execute("SET sql_mode=%s", (self.sql_mode,)) 1750s c.close() 1750s 1750s if self.init_command is not None: 1750s c = self.cursor() 1750s c.execute(self.init_command) 1750s c.close() 1750s 1750s if self.autocommit_mode is not None: 1750s self.autocommit(self.autocommit_mode) 1750s except BaseException as e: 1750s self._rfile = None 1750s if sock is not None: 1750s try: 1750s sock.close() 1750s except: # noqa 1750s pass 1750s 1750s if isinstance(e, (OSError, IOError)): 1750s exc = err.OperationalError( 1750s CR.CR_CONN_HOST_ERROR, 1750s f"Can't connect to MySQL server on {self.host!r} ({e})", 1750s ) 1750s # Keep original exception and traceback to investigate error. 1750s exc.original_exception = e 1750s exc.traceback = traceback.format_exc() 1750s if DEBUG: 1750s print(exc.traceback) 1750s > raise exc 1750s E sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)") 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/pymysql/connections.py:716: OperationalError 1750s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] _ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s request = > 1750s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s conn = request.getfixturevalue(conn) 1750s table = "test" 1750s df = DataFrame({"a": [1, 2, 3], "b": 5}) 1750s > df.to_sql(name=table, con=conn, index=False, if_exists="replace") 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3760: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/pandas/util/_decorators.py:333: in wrapper 1750s return func(*args, **kwargs) 1750s /usr/lib/python3/dist-packages/pandas/core/generic.py:3087: in to_sql 1750s return sql.to_sql( 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:841: in to_sql 1750s with pandasSQL_builder(con, schema=schema, need_transaction=True) as pandas_sql: 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:906: in pandasSQL_builder 1750s return SQLDatabase(con, schema, need_transaction) 1750s /usr/lib/python3/dist-packages/pandas/io/sql.py:1636: in __init__ 1750s con = self.exit_stack.enter_context(con.connect()) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _ test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] __ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s conn = 'postgresql_psycopg2_conn' 1750s request = > 1750s func = 'read_sql_query', dtype_backend = 'numpy_nullable' 1750s 1750s @pytest.mark.parametrize("conn", all_connectable) 1750s @pytest.mark.parametrize("dtype_backend", [lib.no_default, "numpy_nullable"]) 1750s @pytest.mark.parametrize("func", ["read_sql", "read_sql_query"]) 1750s def test_read_sql_dtype(conn, request, func, dtype_backend): 1750s # GH#50797 1750s > conn = request.getfixturevalue(conn) 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3757: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:532: in getfixturevalue 1750s fixturedef = self._get_active_fixturedef(argname) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:617: in _get_active_fixturedef 1750s fixturedef.execute(request=subrequest) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1091: in execute 1750s result = ihook.pytest_fixture_setup(fixturedef=self, request=request) 1750s /usr/lib/python3/dist-packages/pluggy/_hooks.py:513: in __call__ 1750s return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/pluggy/_manager.py:120: in _hookexec 1750s return self._inner_hookexec(hook_name, methods, kwargs, firstresult) 1750s /usr/lib/python3/dist-packages/_pytest/setuponly.py:36: in pytest_fixture_setup 1750s return (yield) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:1140: in pytest_fixture_setup 1750s result = call_fixture_func(fixturefunc, request, kwargs) 1750s /usr/lib/python3/dist-packages/_pytest/fixtures.py:891: in call_fixture_func 1750s fixture_result = next(generator) 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:681: in postgresql_psycopg2_conn 1750s with postgresql_psycopg2_engine.connect() as conn: 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _________________________ test_psycopg2_schema_support _________________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s 1750s @pytest.mark.db 1750s def test_psycopg2_schema_support(postgresql_psycopg2_engine): 1750s conn = postgresql_psycopg2_engine 1750s 1750s # only test this for postgresql (schema's not supported in 1750s # mysql/sqlite) 1750s df = DataFrame({"col1": [1, 2], "col2": [0.1, 0.2], "col3": ["a", "n"]}) 1750s 1750s # create a schema 1750s > with conn.connect() as con: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3905: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s _________________________ test_self_join_date_columns __________________________ 1750s self = 1750s engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s connection = None, _has_events = None, _allow_revalidate = True 1750s _allow_autobegin = True 1750s 1750s def __init__( 1750s self, 1750s engine: Engine, 1750s connection: Optional[PoolProxiedConnection] = None, 1750s _has_events: Optional[bool] = None, 1750s _allow_revalidate: bool = True, 1750s _allow_autobegin: bool = True, 1750s ): 1750s """Construct a new Connection.""" 1750s self.engine = engine 1750s self.dialect = dialect = engine.dialect 1750s 1750s if connection is None: 1750s try: 1750s > self._dbapi_connection = engine.raw_connection() 1750s 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s 1750s The above exception was the direct cause of the following exception: 1750s 1750s postgresql_psycopg2_engine = Engine(postgresql+psycopg2://postgres:***@localhost:5432/pandas) 1750s 1750s @pytest.mark.db 1750s def test_self_join_date_columns(postgresql_psycopg2_engine): 1750s # GH 44421 1750s conn = postgresql_psycopg2_engine 1750s from sqlalchemy.sql import text 1750s 1750s create_table = text( 1750s """ 1750s CREATE TABLE person 1750s ( 1750s id serial constraint person_pkey primary key, 1750s created_dt timestamp with time zone 1750s ); 1750s 1750s INSERT INTO person 1750s VALUES (1, '2021-01-01T00:00:00Z'); 1750s """ 1750s ) 1750s > with conn.connect() as con: 1750s 1750s /usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3989: 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3274: in connect 1750s return self._connection_cls(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:148: in __init__ 1750s Connection._handle_dbapi_exception_noconnection( 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:2439: in _handle_dbapi_exception_noconnection 1750s raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:146: in __init__ 1750s self._dbapi_connection = engine.raw_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/base.py:3298: in raw_connection 1750s return self.pool.connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:449: in connect 1750s return _ConnectionFairy._checkout(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:1263: in _checkout 1750s fairy = _ConnectionRecord.checkout(pool) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:712: in checkout 1750s rec = pool._do_get() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/impl.py:308: in _do_get 1750s return self._create_connection() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:390: in _create_connection 1750s return _ConnectionRecord(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:674: in __init__ 1750s self.__connect() 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:900: in __connect 1750s with util.safe_reraise(): 1750s /usr/lib/python3/dist-packages/sqlalchemy/util/langhelpers.py:146: in __exit__ 1750s raise exc_value.with_traceback(exc_tb) 1750s /usr/lib/python3/dist-packages/sqlalchemy/pool/base.py:896: in __connect 1750s self.dbapi_connection = connection = pool._invoke_creator(self) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/create.py:646: in connect 1750s return dialect.connect(*cargs, **cparams) 1750s /usr/lib/python3/dist-packages/sqlalchemy/engine/default.py:622: in connect 1750s return self.loaded_dbapi.connect(*cargs, **cparams) 1750s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 1750s 1750s dsn = 'host=localhost dbname=pandas user=postgres password=postgres port=5432' 1750s connection_factory = None, cursor_factory = None 1750s kwargs = {'dbname': 'pandas', 'host': 'localhost', 'password': 'postgres', 'port': 5432, ...} 1750s kwasync = {} 1750s 1750s def connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs): 1750s """ 1750s Create a new database connection. 1750s 1750s The connection parameters can be specified as a string: 1750s 1750s conn = psycopg2.connect("dbname=test user=postgres password=secret") 1750s 1750s or using a set of keyword arguments: 1750s 1750s conn = psycopg2.connect(database="test", user="postgres", password="secret") 1750s 1750s Or as a mix of both. The basic connection parameters are: 1750s 1750s - *dbname*: the database name 1750s - *database*: the database name (only as keyword argument) 1750s - *user*: user name used to authenticate 1750s - *password*: password used to authenticate 1750s - *host*: database host address (defaults to UNIX socket if not provided) 1750s - *port*: connection port number (defaults to 5432 if not provided) 1750s 1750s Using the *connection_factory* parameter a different class or connections 1750s factory can be specified. It should be a callable object taking a dsn 1750s argument. 1750s 1750s Using the *cursor_factory* parameter, a new default cursor factory will be 1750s used by cursor(). 1750s 1750s Using *async*=True an asynchronous connection will be created. *async_* is 1750s a valid alias (for Python versions where ``async`` is a keyword). 1750s 1750s Any other keyword parameter will be passed to the underlying client 1750s library: the list of supported parameters depends on the library version. 1750s 1750s """ 1750s kwasync = {} 1750s if 'async' in kwargs: 1750s kwasync['async'] = kwargs.pop('async') 1750s if 'async_' in kwargs: 1750s kwasync['async_'] = kwargs.pop('async_') 1750s 1750s dsn = _ext.make_dsn(dsn, **kwargs) 1750s > conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 1750s E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused 1750s E Is the server running on that host and accepting TCP/IP connections? 1750s E 1750s E (Background on this error at: https://sqlalche.me/e/20/e3q8) 1750s 1750s /usr/lib/python3/dist-packages/psycopg2/__init__.py:122: OperationalError 1750s =============================== warnings summary =============================== 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:895 1750s /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 1750s pytest.param("mysql_pymysql_engine", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:896 1750s /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 1750s pytest.param("mysql_pymysql_conn", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:900 1750s /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 1750s pytest.param("mysql_pymysql_engine_iris", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:901 1750s /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 1750s pytest.param("mysql_pymysql_conn_iris", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:905 1750s /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 1750s pytest.param("mysql_pymysql_engine_types", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:906 1750s /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 1750s pytest.param("mysql_pymysql_conn_types", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:910 1750s /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 1750s pytest.param("postgresql_psycopg2_engine", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:911 1750s /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 1750s pytest.param("postgresql_psycopg2_conn", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:915 1750s /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 1750s pytest.param("postgresql_psycopg2_engine_iris", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:916 1750s /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 1750s pytest.param("postgresql_psycopg2_conn_iris", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:920 1750s /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 1750s pytest.param("postgresql_psycopg2_engine_types", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:921 1750s /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 1750s pytest.param("postgresql_psycopg2_conn_types", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:954 1750s /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 1750s pytest.param("postgresql_adbc_conn", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:958 1750s /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 1750s pytest.param("postgresql_adbc_iris", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:959 1750s /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 1750s pytest.param("sqlite_adbc_iris", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:963 1750s /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 1750s pytest.param("postgresql_adbc_types", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:964 1750s /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 1750s pytest.param("sqlite_adbc_types", marks=pytest.mark.db), 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3896 1750s /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 1750s @pytest.mark.db 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py:3971 1750s /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 1750s @pytest.mark.db 1750s 1750s ../../../usr/lib/python3/dist-packages/pandas/tests/tools/test_to_datetime.py:1143 1750s /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 1750s @pytest.mark.skip_ubsan 1750s 1750s io/test_sql.py: 1535 warnings 1750s tools/test_to_datetime.py: 978 warnings 1750s /usr/lib/python3/dist-packages/py/_process/forkedfunc.py:45: DeprecationWarning: This process (pid=18586) is multi-threaded, use of fork() may lead to deadlocks in the child. 1750s pid = os.fork() 1750s 1750s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:475 1750s /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-0werruke' 1750s config.cache.set("cache/nodeids", sorted(self.cached_nodeids)) 1750s 1750s ../../../usr/lib/python3/dist-packages/_pytest/cacheprovider.py:429 1750s /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-lktqu2vv' 1750s config.cache.set("cache/lastfailed", self.lastfailed) 1750s 1750s ../../../usr/lib/python3/dist-packages/_pytest/stepwise.py:51 1750s /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-ynjmdz_e' 1750s session.config.cache.set(STEPWISE_CACHE_DIR, []) 1750s 1750s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 1750s =========================== short test summary info ============================ 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 1750s FAILED ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dataframe_to_sql_empty[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[None-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql[multi-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[replace-1-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist[append-2-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_exist_fail[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_chunksize[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_expression_with_parameter[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_query_string_with_parameter[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_iris_table_chunksize[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_callable[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[mysql_pymysql_conn_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_type_conversion[postgresql_psycopg2_conn_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_procedure[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[2-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_copy_from_callable_insertion_method[Success!-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_do_nothing[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_on_public_schema[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_insertion_method_on_conflict_update[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_view_postgres[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_parameter[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_iris_named_parameter[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_view[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_with_chunksize_no_result[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_fail[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_replace[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_append[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_type_mapping[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_series[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_roundtrip_chunksize[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_execute_sql[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[mysql_pymysql_conn_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_parsing[postgresql_psycopg2_conn_types] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[mysql_pymysql_conn_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_date_and_index[postgresql_psycopg2_conn_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_timedelta[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_complex_raises[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-None-index-postgresql_psycopg2_conn] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[0-None-0-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label[None-0-0-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_to_sql_index_label_multiindex[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_multiindex_roundtrip[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[None-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[int-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[float-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_dtype_argument[dtype3-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_integer_col_names[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_with_schema[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_dtypes[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_get_schema_keys[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_chunksize_read[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_categorical[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_unicode_column_name[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_escaped_table_name[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_api_read_sql_duplicate_columns[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_columns[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_index_col[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_delegate[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_warning_case_insensitive_table_name[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_type_mapping[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int8-SMALLINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int8-SMALLINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint8-SMALLINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt8-SMALLINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int16-SMALLINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int16-SMALLINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint16-INTEGER-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt16-INTEGER-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int32-INTEGER-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int32-INTEGER-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[uint32-BIGINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[UInt32-BIGINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int64-BIGINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[Int64-BIGINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_mapping[int-BIGINT-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[uint64-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_integer_overload_mapping[UInt64-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_database_uri_string[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_pg8000_sqlalchemy_passthrough_error[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_text_obj[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_query_by_select_obj[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_column_with_percentage[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_create_table[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_drop_table[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_roundtrip[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_execute_sql[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_read_table_columns[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[mysql_pymysql_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_engine_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_table_absent_raises[postgresql_psycopg2_conn_iris] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_sqlalchemy_default_type_conversion[postgresql_psycopg2_conn_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_bigint[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[mysql_pymysql_conn_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_default_date_load[postgresql_psycopg2_conn_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[None-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query[parse_dates1-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_query_chunksize[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_table[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_with_timezone_roundtrip[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_out_of_bounds_datetime[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_naive_datetimeindex_roundtrip[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[mysql_pymysql_conn_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_engine_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_date_parsing[postgresql_psycopg2_conn_types] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_NaT[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_date[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_datetime_time[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_mixed_dtype_insert[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_numeric[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_fullcolumn[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_nan_string[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_save_index[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transactions[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_transaction_rollback[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_get_schema_create_table[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_dtype[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_notna_dtype[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_double_precision[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_connectable_issue_example[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input0-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input1-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_negative_npinf[input2-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_temporary_table[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_invalid_engine[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_to_sql_with_sql_engine[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_sqlalchemy[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_options_auto[postgresql_psycopg2_conn] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_invalid_dtype_backend_table[read_sql-postgresql_psycopg2_conn] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_chunksize_empty_dtypes[postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-_NoDefault.no_default-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql-numpy_nullable-postgresql_psycopg2_conn] 1750s 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] 1750s 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] 1750s 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] 1750s 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] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-mysql_pymysql_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_engine] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_read_sql_dtype[read_sql_query-numpy_nullable-postgresql_psycopg2_conn] 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_psycopg2_schema_support 1750s ERROR ../../../usr/lib/python3/dist-packages/pandas/tests/io/test_sql.py::test_self_join_date_columns 1750s = 588 failed, 1481 passed, 400 skipped, 54 xfailed, 2536 warnings, 592 errors in 596.15s (0:09:56) = 1750s autopkgtest [21:05:19]: test ignoredtests: -----------------------] 1751s autopkgtest [21:05:20]: test ignoredtests: - - - - - - - - - - results - - - - - - - - - - 1751s ignoredtests PASS 1752s autopkgtest [21:05:21]: @@@@@@@@@@@@@@@@@@@@ summary 1752s command1 PASS 1752s unittests3 FAIL non-zero exit status 1 1752s ignoredtests PASS 1814s nova [W] Skipping flock for amd64 1814s Creating nova instance adt-questing-i386-pandas-20250605-203609-juju-7f2275-prod-proposed-migration-environment-23-ed83df8c-3f8f-4a29-ad14-3ceffaeaa5da from image adt/ubuntu-questing-amd64-server-20250605.img (UUID 45f30bc4-80eb-46e1-b207-2b072dfeebbd)... 1814s nova [W] Timed out waiting for 1441bc85-b9c3-4e9c-a1bf-533dc727b397 to get deleted.